Skip to content

Instantly share code, notes, and snippets.

@ivangonekrazy
Created April 7, 2015 02:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivangonekrazy/cb7d074678cde5f868f9 to your computer and use it in GitHub Desktop.
Save ivangonekrazy/cb7d074678cde5f868f9 to your computer and use it in GitHub Desktop.
import logging import logging.config
LOGGING_CONFIG = {
'version': 1, # required
'disable_existing_loggers': True, # this config overrides all other loggers
'formatters': {
'simple': {
'format': '%(asctime)s %(levelname)s -- %(message)s'
},
'whenAndWhere': {
'format': '%(asctime)s\t%(levelname)s -- %(processName)s %(filename)s:%(lineno)s -- %(message)s'
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'whenAndWhere'
}
},
'loggers': {
'': { # 'root' logger
'level': 'CRITICAL',
'handlers': ['console']
}
}
}
logging.config.dictConfig(LOGGING_CONFIG)
log = logging.getLogger('') # factory method
log.warn('Citizens of Earth, be warned!')
log.critical('Your planet will be destroyed in 3, 2, 1...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment