Browse Source

Added log_level for logging target

master
Dirk Alders 1 year ago
parent
commit
b53dd30eae
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      __init__.py

+ 3
- 3
__init__.py View File

163
         return json.dumps(obj)
163
         return json.dumps(obj)
164
 
164
 
165
 
165
 
166
-def appLoggingConfigure(basepath, target, log_name_lvl=[], fmt=SHORT_FMT, ring_logs=None, host=None, port=None):
166
+def appLoggingConfigure(basepath, target, log_name_lvl=[], target_level=logging.DEBUG, fmt=SHORT_FMT, ring_logs=None, host=None, port=None):
167
     target_handlers = ['main', ]
167
     target_handlers = ['main', ]
168
     # define handler
168
     # define handler
169
     #
169
     #
170
     if target == 'stdout':
170
     if target == 'stdout':
171
         handler = dict(main={
171
         handler = dict(main={
172
-            'level': 'DEBUG',
172
+            'level': logging.getLevelName(target_level),
173
             'formatter': 'format',
173
             'formatter': 'format',
174
             'class': 'logging.StreamHandler',
174
             'class': 'logging.StreamHandler',
175
             'stream': 'ext://sys.stdout',
175
             'stream': 'ext://sys.stdout',
176
         })
176
         })
177
     elif target == 'logfile':
177
     elif target == 'logfile':
178
         handler = dict(main={
178
         handler = dict(main={
179
-            'level': 'DEBUG',
179
+            'level': logging.getLevelName(target_level),
180
             'formatter': 'json',
180
             'formatter': 'json',
181
             'class': 'logging.handlers.RotatingFileHandler',
181
             'class': 'logging.handlers.RotatingFileHandler',
182
             'filename': os.path.join(basepath, 'messages.log'),
182
             'filename': os.path.join(basepath, 'messages.log'),

Loading…
Cancel
Save