Last active
August 29, 2015 14:24
-
-
Save micktwomey/c6e6ad9d540e3c6a95c3 to your computer and use it in GitHub Desktop.
Minimal useful python logging config
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
""" | |
I always forget a useful default format for python logging, so here's one I prepared earlier. | |
""" | |
import logging | |
logging.basicConfig(level=logging.DEBUG, | |
format=('%(asctime)s %(levelname)s %(name)s ' | |
'%(pathname)s:%(lineno)d %(message)s' | |
), | |
datefmt="%Y-%m-%d %H:%M:%S%z") | |
logging.info("ham") # 2015-07-15 10:20:07+0100 INFO root <stdin>:1 ham |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment