Refactor code

This commit is contained in:
PCoder 2017-11-29 07:32:17 +01:00
parent 6e82add935
commit b6e734d84e

View file

@ -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,