Refactor code
This commit is contained in:
parent
6e82add935
commit
b6e734d84e
1 changed files with 8 additions and 22 deletions
|
@ -573,31 +573,19 @@ if DCL_ERROR_EMAILS_TO is not None:
|
||||||
if 'info@ungleich.ch' not in DCL_ERROR_EMAILS_TO_LIST:
|
if 'info@ungleich.ch' not in DCL_ERROR_EMAILS_TO_LIST:
|
||||||
DCL_ERROR_EMAILS_TO_LIST.append('info@ungleich.ch')
|
DCL_ERROR_EMAILS_TO_LIST.append('info@ungleich.ch')
|
||||||
|
|
||||||
ENABLE_DEBUG_LOGGING = bool_env('ENABLE_DEBUG_LOGGING')
|
ENABLE_LOGGING = bool_env('ENABLE_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),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
MODULES_TO_LOG = env('MODULES_TO_LOG')
|
MODULES_TO_LOG = env('MODULES_TO_LOG')
|
||||||
LOG_LEVEL = env('LOG_LEVEL')
|
LOG_LEVEL = env('LOG_LEVEL')
|
||||||
|
|
||||||
if LOG_LEVEL is None:
|
if LOG_LEVEL is None:
|
||||||
LOG_LEVEL = 'DEBUG'
|
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:
|
if ',' in MODULES_TO_LOG:
|
||||||
modules_to_log_list = MODULES_TO_LOG.split(',')
|
modules_to_log_list = MODULES_TO_LOG.split(',')
|
||||||
for custom_module in modules_to_log_list:
|
for custom_module in modules_to_log_list:
|
||||||
|
@ -624,15 +612,13 @@ if MODULES_TO_LOG:
|
||||||
'level': LOG_LEVEL,
|
'level': LOG_LEVEL,
|
||||||
'class': 'logging.FileHandler',
|
'class': 'logging.FileHandler',
|
||||||
'filename':
|
'filename':
|
||||||
"{PROJECT_DIR}/custom_{LEVEL}.log".format(
|
"{PROJECT_DIR}/{LEVEL}.log".format(
|
||||||
LEVEL=LOG_LEVEL.lower(),
|
LEVEL=LOG_LEVEL.lower(),
|
||||||
PROJECT_DIR=PROJECT_DIR
|
PROJECT_DIR=PROJECT_DIR
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handlers_dict.update(custom_handler_item)
|
handlers_dict.update(custom_handler_item)
|
||||||
|
|
||||||
if ENABLE_DEBUG_LOGGING:
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
'version': 1,
|
||||||
'disable_existing_loggers': False,
|
'disable_existing_loggers': False,
|
||||||
|
|
Loading…
Reference in a new issue