Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
settingsd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
settingsd
Commits
a7396265
Commit
a7396265
authored
Oct 05, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added log coloring
parent
52014a4c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
config.py
settingsd/config.py
+2
-1
const.py
settingsd/const.py
+1
-0
logger.py
settingsd/logger.py
+9
-1
No files found.
settingsd/config.py
View file @
a7396265
...
...
@@ -25,7 +25,8 @@ ConfigDictObject = {
"service_name"
:
(
const
.
DEFAULT_SERVICE_NAME
,
str
),
"service_path"
:
(
const
.
DEFAULT_SERVICE_PATH
,
str
),
"bus_type"
:
(
const
.
DEFAULT_BUS_TYPE
,
(
lambda
arg
:
validators
.
validRange
(
arg
,
const
.
ALL_BUS_TYPES_LIST
)
)),
"log_level"
:
(
const
.
DEFAULT_LOG_LEVEL
,
(
lambda
arg
:
validators
.
validRange
(
int
(
arg
),
const
.
ALL_LOG_LEVELS_LIST
)
))
"log_level"
:
(
const
.
DEFAULT_LOG_LEVEL
,
(
lambda
arg
:
validators
.
validRange
(
int
(
arg
),
const
.
ALL_LOG_LEVELS_LIST
)
)),
"log_use_colors"
:(
const
.
DEFAULT_LOG_USE_COLORS_FLAG
,
validators
.
validBool
)
},
RUNTIME_SECTION
:
{
"bus_name"
:
(
None
,
None
),
...
...
settingsd/const.py
View file @
a7396265
...
...
@@ -33,4 +33,5 @@ DEFAULT_SERVICE_NAME = "org.etersoft.%s" % (MY_NAME)
DEFAULT_SERVICE_PATH
=
"/org/etersoft/
%
s"
%
(
MY_NAME
)
DEFAULT_BUS_TYPE
=
BUS_TYPE_SYSTEM
DEFAULT_LOG_LEVEL
=
LOG_LEVEL_INFO
DEFAULT_LOG_USE_COLORS_FLAG
=
True
settingsd/logger.py
View file @
a7396265
...
...
@@ -38,7 +38,15 @@ def log(message_type, message) :
raise
UnknownMessageType
(
"Message type
\"
%
d
\"
not in list
%
s"
%
(
message_type
,
ALL_MESSAGES_LIST
))
if
message_type
[
2
]
<=
config
.
value
(
config
.
APPLICATION_SECTION
,
"log_level"
)
:
message_type_texts_list
=
(
"Error"
,
"Warning"
,
"Notice"
,
"Info"
,
"Details"
,
"Debug"
)
use_colors_flag
=
sys
.
stderr
.
isatty
()
and
config
.
value
(
config
.
APPLICATION_SECTION
,
"log_use_colors"
)
message_type_texts_list
=
(
(
"
\033
[31mError
\033
[0m"
if
use_colors_flag
else
"Error"
),
(
"
\033
[33mWarning
\033
[0m"
if
use_colors_flag
else
"Warning"
),
(
"
\033
[32mNotice
\033
[0m"
if
use_colors_flag
else
"Notice"
),
(
"
\033
[32mInfo
\033
[0m"
if
use_colors_flag
else
"Info"
),
(
"
\033
[36mDetails
\033
[0m"
if
use_colors_flag
else
"Details"
),
"Debug"
)
message
=
"[
%
s ]:
%
s"
%
(
message_type_texts_list
[
message_type
[
0
]],
message
)
print
>>
sys
.
stderr
,
const
.
MY_NAME
,
message
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment