Commit 38c7283c authored by PCoder's avatar PCoder

Enable logging by setting by setting `ENABLE_DEBUG_LOG` in .env

Also set the modules to log by using `MODULES_TO_LOG` config
parameter in .env
parent bbb6f329
......@@ -206,3 +206,34 @@ LOGGING = {
},
},
}
if config('ENABLE_DEBUG_LOG', False):
loggers_dict = {}
LOGGING['handlers']['file'] = {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': os.path.join(BASE_DIR, 'debug.log'),
}
MODULES_TO_LOG = config('MODULES_TO_LOG', 'django')
LOGGING['handlers']['file'] = {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': os.path.join(BASE_DIR, 'debug.log'),
}
if MODULES_TO_LOG is None:
# set MODULES_TO_LOG to django, if it is not set
MODULES_TO_LOG = 'django'
modules_to_log_list = MODULES_TO_LOG.split(',')
for custom_module in modules_to_log_list:
logger_item = {
custom_module: {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True
}
}
loggers_dict.update(logger_item)
LOGGING['loggers'] = loggers_dict
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment