Skip to content

Instantly share code, notes, and snippets.

@deliseev
Created August 28, 2019 13:12
Show Gist options
  • Save deliseev/f0de4ca59fd88523f8ec5ff12af8a2ed to your computer and use it in GitHub Desktop.
Save deliseev/f0de4ca59fd88523f8ec5ff12af8a2ed to your computer and use it in GitHub Desktop.
Color logger for django
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'colored': {
'()': 'colorlog.ColoredFormatter',
'format': "%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s",
'log_colors': {
'DEBUG': 'bold_black',
'INFO': 'white',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'bold_red',
},
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'level': 'DEBUG',
'formatter': 'colored',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
'propagate': True,
},
'core': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment