Teil 27: logging.config
This commit is contained in:
10
teil27/JSONFormatter.py
Normal file
10
teil27/JSONFormatter.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import logging
|
||||
import logging.config
|
||||
import json
|
||||
ATTR_TO_JSON = ['created', 'filename', 'funcName', 'levelname', 'lineno', 'module', 'msecs', 'msg', 'name', 'pathname', 'process', 'processName', 'relativeCreated', 'thread', 'threadName']
|
||||
class JsonFormatter:
|
||||
def format(self, record):
|
||||
obj = {attr: getattr(record, attr)
|
||||
for attr in ATTR_TO_JSON}
|
||||
return json.dumps(obj, indent=4)
|
||||
|
Reference in New Issue
Block a user