Improve log formatting

This commit is contained in:
PCoder 2019-04-13 12:04:18 +02:00
parent 4cf7b93ee2
commit f50af4f2aa
2 changed files with 11 additions and 3 deletions

View file

@ -685,18 +685,26 @@ if ENABLE_LOGGING:
custom_handler_item = { custom_handler_item = {
'custom_file': { 'custom_file': {
'level': LOG_LEVEL, 'level': LOG_LEVEL,
'class': 'logging.FileHandler', 'class': 'logging.handlers.RotatingFileHandler',
'filename': 'filename':
"{PROJECT_DIR}/{LEVEL}.log".format( "{PROJECT_DIR}/logs/{LEVEL}.log".format(
LEVEL=LOG_LEVEL.lower(), LEVEL=LOG_LEVEL.lower(),
PROJECT_DIR=PROJECT_DIR PROJECT_DIR=PROJECT_DIR
) ),
'maxBytes': 1024 * 1024 * 5,
'backupCount': 10,
'formatter': 'standard',
} }
} }
handlers_dict.update(custom_handler_item) handlers_dict.update(custom_handler_item)
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': False, 'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s %(levelname)s %(name)s: %(message)s'
}
},
'handlers': handlers_dict, 'handlers': handlers_dict,
'loggers': loggers_dict 'loggers': loggers_dict
} }