Browse Source

stdout logging configuration added

master
Dirk Alders 5 years ago
parent
commit
b9184d3e41
1 changed files with 17 additions and 11 deletions
  1. 17
    11
      __init__.py

+ 17
- 11
__init__.py View File

151
         self.MY_LOGS.append(record.__dict__)
151
         self.MY_LOGS.append(record.__dict__)
152
         self.MY_LOGS[-1]['moduleLogger'] = collectingHandler().get_logs()
152
         self.MY_LOGS[-1]['moduleLogger'] = collectingHandler().get_logs()
153
 
153
 
154
-
155
 def appLoggingConfigure(basepath, target, log_name_lvl=[], fmt=SHORT_FMT, ring_logs=None):
154
 def appLoggingConfigure(basepath, target, log_name_lvl=[], fmt=SHORT_FMT, ring_logs=None):
156
-    target_handlers = ['main', 'logwarn']
155
+    target_handlers = ['main', ]
156
+    if basepath is not None:
157
+        target_handlers.append('logwarn')
157
     # define handler
158
     # define handler
158
     #
159
     #
159
     if target == 'stdout':
160
     if target == 'stdout':
185
             'class': 'report.collectingRingHandler',
186
             'class': 'report.collectingRingHandler',
186
             'max_logs': ring_logs,
187
             'max_logs': ring_logs,
187
         }
188
         }
188
-    handler['logwarn'] = {
189
-        'level': 'WARNING',
190
-        'formatter': 'long',
191
-        'class': 'logging.handlers.RotatingFileHandler',
192
-        'filename': os.path.join(basepath, 'messages.warn'),
193
-        'mode': 'a',
194
-        'maxBytes': 10485760,
195
-        'backupCount': 2
196
-    }
189
+    if basepath is not None:
190
+        handler['logwarn'] = {
191
+            'level': 'WARNING',
192
+            'formatter': 'long',
193
+            'class': 'logging.handlers.RotatingFileHandler',
194
+            'filename': os.path.join(basepath, 'messages.warn'),
195
+            'mode': 'a',
196
+            'maxBytes': 10485760,
197
+             'backupCount': 2
198
+        }
197
     # define loggers
199
     # define loggers
198
     #
200
     #
199
     loggers = {}
201
     loggers = {}
220
     ))
222
     ))
221
 
223
 
222
 
224
 
225
+def stdoutLoggingConfigure(log_name_lvl=[], fmt=SHORT_FMT):
226
+    appLoggingConfigure(None, 'stdout', log_name_lvl=log_name_lvl, fmt=fmt)
227
+
228
+
223
 class testSession(dict):
229
 class testSession(dict):
224
     KEY_NAME = 'name'
230
     KEY_NAME = 'name'
225
     KEY_FAILED_TESTS = 'number_of_failed_tests'
231
     KEY_FAILED_TESTS = 'number_of_failed_tests'

Loading…
Cancel
Save