Last active
September 8, 2015 12:21
-
-
Save boyvinall/ed8a55dba262a96a79cd to your computer and use it in GitHub Desktop.
python logger setup
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
import logging | |
logging.basicConfig(level=logging.DEBUG, | |
format='[%(created)s] p%(process)s {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', | |
datefmt='%H:%M:%S', | |
filename='/path/to/foo-' + time.strftime("%Y%m%d-%H%M") + '.log', | |
filemode='w') | |
console = logging.StreamHandler() | |
console.setLevel(logging.INFO) | |
formatter = logging.Formatter('%(levelname)s %(message)s') | |
console.setFormatter(formatter) | |
logging.getLogger('').addHandler(console) | |
# do stuff.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment