From b6e734d84e42c20b6469cde69f7ab8fcd6f4ac84 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 29 Nov 2017 07:32:17 +0100 Subject: [PATCH] Refactor code --- dynamicweb/settings/base.py | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 10cdf40c..3f40d8a7 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -573,31 +573,19 @@ if DCL_ERROR_EMAILS_TO is not None: if 'info@ungleich.ch' not in DCL_ERROR_EMAILS_TO_LIST: DCL_ERROR_EMAILS_TO_LIST.append('info@ungleich.ch') -ENABLE_DEBUG_LOGGING = bool_env('ENABLE_DEBUG_LOGGING') - -loggers_dict = { - 'django': { - 'handlers': ['file'], - 'level': 'DEBUG', - 'propagate': True, - }, - } -handlers_dict = { - 'file': { - 'level': 'DEBUG', - 'class': 'logging.FileHandler', - 'filename': "{PROJECT_DIR}/django-debug.log".format( - PROJECT_DIR=PROJECT_DIR), - }, -} - +ENABLE_LOGGING = bool_env('ENABLE_LOGGING') MODULES_TO_LOG = env('MODULES_TO_LOG') LOG_LEVEL = env('LOG_LEVEL') if LOG_LEVEL is None: LOG_LEVEL = 'DEBUG' -if MODULES_TO_LOG: +if ENABLE_LOGGING: + loggers_dict = {} + handlers_dict = {} + if MODULES_TO_LOG is None: + # set MODULES_TO_LOG to django, if it is not set + MODULES_TO_LOG = 'django' if ',' in MODULES_TO_LOG: modules_to_log_list = MODULES_TO_LOG.split(',') for custom_module in modules_to_log_list: @@ -624,15 +612,13 @@ if MODULES_TO_LOG: 'level': LOG_LEVEL, 'class': 'logging.FileHandler', 'filename': - "{PROJECT_DIR}/custom_{LEVEL}.log".format( + "{PROJECT_DIR}/{LEVEL}.log".format( LEVEL=LOG_LEVEL.lower(), PROJECT_DIR=PROJECT_DIR ) } } handlers_dict.update(custom_handler_item) - -if ENABLE_DEBUG_LOGGING: LOGGING = { 'version': 1, 'disable_existing_loggers': False,