Created
April 7, 2015 02:07
-
-
Save ivangonekrazy/cb7d074678cde5f868f9 to your computer and use it in GitHub Desktop.
This file contains 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
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