You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
418 B
11 lines
418 B
1 month ago
|
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)
|
||
|
|