Created
February 10, 2019 20:33
-
-
Save pcoder/908b6f7c7cb7fd8cb324cbacc45ff0d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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