From 0fce4628180b18d6c90f4ddff5b7958374f4a93c Mon Sep 17 00:00:00 2001 From: Tiberiu Chibici Date: Sun, 30 Dec 2018 00:10:30 +0200 Subject: [PATCH] Fixed issues with log not working. --- app/YtManager/settings.py | 1 + app/YtManagerApp/appmain.py | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/YtManager/settings.py b/app/YtManager/settings.py index 8fa0aad..334879e 100644 --- a/app/YtManager/settings.py +++ b/app/YtManager/settings.py @@ -118,6 +118,7 @@ MEDIA_URL = '/media/' CRISPY_TEMPLATE_PACK = 'bootstrap4' LOG_FORMAT = '%(asctime)s|%(process)d|%(thread)d|%(name)s|%(filename)s|%(lineno)d|%(levelname)s|%(message)s' +CONSOLE_LOG_FORMAT = '%(asctime)s | %(name)s | %(filename)s:%(lineno)d | %(levelname)s | %(message)s' # # Directories diff --git a/app/YtManagerApp/appmain.py b/app/YtManagerApp/appmain.py index 03e3ae7..8054260 100644 --- a/app/YtManagerApp/appmain.py +++ b/app/YtManagerApp/appmain.py @@ -22,18 +22,17 @@ def __initialize_logger(): maxBytes=1024 * 1024, backupCount=5 ) - handlers.append(file_handler) + file_handler.setLevel(dj_settings.LOG_LEVEL) + file_handler.setFormatter(logging.Formatter(dj_settings.LOG_FORMAT)) + logging.root.addHandler(file_handler) + logging.root.setLevel(dj_settings.LOG_LEVEL) if dj_settings.DEBUG: console_handler = logging.StreamHandler(stream=sys.stdout) console_handler.setLevel(logging.DEBUG) - handlers.append(console_handler) + console_handler.setFormatter(logging.Formatter(dj_settings.CONSOLE_LOG_FORMAT)) + logging.root.addHandler(console_handler) - logging.basicConfig( - level=dj_settings.LOG_LEVEL, - format=dj_settings.LOG_FORMAT, - handlers=handlers - ) def main():