Skip to content

Instantly share code, notes, and snippets.

@pcoder
Created February 10, 2019 20:33
Show Gist options
  • Save pcoder/908b6f7c7cb7fd8cb324cbacc45ff0d7 to your computer and use it in GitHub Desktop.
Save pcoder/908b6f7c7cb7fd8cb324cbacc45ff0d7 to your computer and use it in GitHub Desktop.
LOGGING = {
'disable_existing_loggers': False,
'version': 1,
'formatters': {
'standard': {
'format': '%(asctime)s %(levelname)s %(name)s: %(message)s'
}
},
'handlers': {
'default': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': 'logs/debug.log',
'maxBytes': 1024*1024*5,
'backupCount': 10,
'formatter': 'standard',
},
'console': {
'class': 'logging.StreamHandler',
},
},
}
if config('ENABLE_DEBUG_LOG', False):
loggers_dict = {}
modules_to_log_list = config(
'MODULES_TO_LOG', default='django', cast=Csv()
)
for custom_module in modules_to_log_list:
logger_item = {
custom_module: {
'handlers': ['default'],
'level': 'DEBUG',
'propagate': True
}
}
loggers_dict.update(logger_item)
LOGGING['loggers'] = loggers_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment