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
6c1c5923
Commit
6c1c5923
authored
Sep 06, 2010
by
Devaev Maxim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some types of messaging, optimized trace decorator
parent
50bcafea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
8 deletions
+37
-8
logger.py
settingsd/logger.py
+34
-6
service.py
settingsd/service.py
+3
-2
No files found.
settingsd/logger.py
View file @
6c1c5923
...
...
@@ -8,13 +8,41 @@ import config
#####
def
message
(
log_level
,
message
)
:
text_log_levels_list
=
[
"
%
s [ Info ]:"
%
(
const
.
MY_NAME
),
# const.LOG_LEVEL_INFO == 0
"
%
s [ Details ]:"
%
(
const
.
MY_NAME
),
# const.LOG_LEVEL_VERBOSE == 1
"
%
s [ Debug ]:"
%
(
const
.
MY_NAME
)
# # const.LOG_LEVEL_DEBUG == 2
]
ERROR_MESSAGE
=
0
INFO_MESSAGE
=
1
VERBOSE_MESSAGE
=
2
DEBUG_MESSAGE
=
3
ALL_MESSAGES_LIST
=
(
ERROR_MESSAGE
,
INFO_MESSAGE
,
VERBOSE_MESSAGE
,
DEBUG_MESSAGE
)
#####
class
UnknownMessageType
(
Exception
)
:
pass
#####
def
message
(
message_type
,
message
)
:
if
message_type
in
(
ERROR_MESSAGE
,
INFO_MESSAGE
)
:
log_level
=
const
.
LOG_LEVEL_INFO
elif
message_type
==
VERBOSE_MESSAGE
:
log_level
=
const
.
LOG_LEVEL_VERBOSE
elif
message_type
==
DEBUG_MESSAGE
:
log_level
=
const
.
LOG_LEVEL_DEBUG
else
:
raise
UnknownMessageType
(
"Message type
\"
%
d
\"
not in list
%
s"
%
(
message_type
,
ALL_MESSAGES_LIST
))
if
log_level
<=
config
.
value
(
"service"
,
"log_level"
)
:
text_log_levels_list
=
(
"
%
s [ Info ]:"
%
(
const
.
MY_NAME
),
"
%
s [ Details ]:"
%
(
const
.
MY_NAME
),
"
%
s [ Debug ]:"
%
(
const
.
MY_NAME
)
)
print
>>
sys
.
stderr
,
text_log_levels_list
[
log_level
],
message
settingsd/service.py
View file @
6c1c5923
...
...
@@ -62,8 +62,9 @@ class ActionObject(CustomObject) :
def
tracer
(
function
)
:
def
wrapper
(
self
,
*
args_list
,
**
kwargs_dict
)
:
return_value
=
function
(
self
,
*
args_list
,
**
kwargs_dict
)
logger
.
message
(
const
.
LOG_LEVEL_DEBUG
,
"Called
\"
%
s::
%
s
\"
with args (
%
s,
%
s) -->
%
s"
%
(
self
.
__class__
.
__name__
,
function
.
__name__
,
str
(
args_list
),
str
(
kwargs_dict
),
str
(
return_value
)
))
if
config
.
value
(
"service"
,
"log_level"
)
==
const
.
LOG_LEVEL_DEBUG
:
logger
.
message
(
logger
.
DEBUG_MESSAGE
,
"Called
\"
%
s::
%
s
\"
with args (
%
s,
%
s) -->
%
s"
%
(
self
.
__class__
.
__name__
,
function
.
__name__
,
str
(
args_list
),
str
(
kwargs_dict
),
str
(
return_value
)
))
return
return_value
wrapper
.
__dict__
=
function
.
__dict__
...
...
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