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
eb90bcac
Commit
eb90bcac
authored
Nov 12, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New {submod} macros for logger
parent
76a73242
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
6 deletions
+22
-6
logger.py
settingsd/logger.py
+22
-6
No files found.
settingsd/logger.py
View file @
eb90bcac
...
...
@@ -28,6 +28,7 @@ ALL_MESSAGES_LIST = (
DEBUG_MESSAGE
)
ALL_MESSAGES_TEXTS_LIST
=
(
(
" Error "
,
"
\033
[31m Error
\033
[0m"
),
(
"Warning"
,
"
\033
[33mWarning
\033
[0m"
),
...
...
@@ -37,9 +38,17 @@ ALL_MESSAGES_TEXTS_LIST = (
(
" Debug "
,
" Debug "
)
)
MODULE_CALLER_NAME_TAG
=
"{mod}"
SUBMODULE_CALLER_NAME_TAG
=
"{submod}"
CURRENT_TIME_TAG
=
"{time}"
ALL_TAGS_LIST
=
(
MODULE_CALLER_NAME_TAG
,
SUBMODULE_CALLER_NAME_TAG
,
CURRENT_TIME_TAG
)
##### Exceptions #####
class
UnknownMessageType
(
Exception
)
:
...
...
@@ -52,12 +61,19 @@ def log(message_type, message) :
raise
UnknownMessageType
(
"Message type
\"
%
s
\"
not in list
%
s"
%
(
str
(
message_type
),
ALL_MESSAGES_LIST
))
if
message_type
[
2
]
<=
config
.
value
(
config
.
APPLICATION_SECTION
,
"log_level"
)
:
if
MODULE_CALLER_NAME_TAG
in
message
:
try
:
message
=
message
.
replace
(
MODULE_CALLER_NAME_TAG
,
inspect
.
getmodule
(
inspect
.
currentframe
()
.
f_back
.
f_back
)
.
__name__
)
except
:
pass
if
CURRENT_TIME_TAG
in
message
:
message
=
message
.
replace
(
CURRENT_TIME_TAG
,
time
.
ctime
())
for
all_tags_list_item
in
ALL_TAGS_LIST
:
if
all_tags_list_item
==
MODULE_CALLER_NAME_TAG
:
try
:
message
=
message
.
replace
(
MODULE_CALLER_NAME_TAG
,
inspect
.
getmodule
(
inspect
.
currentframe
()
.
f_back
.
f_back
)
.
__name__
)
except
:
pass
elif
all_tags_list_item
==
SUBMODULE_CALLER_NAME_TAG
:
try
:
message
=
message
.
replace
(
SUBMODULE_CALLER_NAME_TAG
,
inspect
.
getmodule
(
inspect
.
currentframe
()
.
f_back
.
f_back
.
f_back
)
.
__name__
)
except
:
pass
elif
all_tags_list_item
==
CURRENT_TIME_TAG
:
message
=
message
.
replace
(
CURRENT_TIME_TAG
,
time
.
ctime
())
colored_index
=
int
(
sys
.
stderr
.
isatty
()
and
config
.
value
(
config
.
APPLICATION_SECTION
,
"log_use_colors"
))
for
message_list_item
in
message
.
split
(
"
\n
"
)
:
...
...
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