Created
January 23, 2018 04:04
-
-
Save santosh/c4c550e686cce26301fd00a4beee7d14 to your computer and use it in GitHub Desktop.
Simplest form of logging in Python.
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 levels | |
# https://docs.python.org/3.6/library/logging.html#logging-levels | |
# https://docs.python.org/3.6/library/logging.html#logrecord-attributes | |
logging.basicConfig(filename='logger.log', | |
filemode='w', | |
format='%(lineno)d %(levelname)s: %(asctime)s %(funcName)s %(message)s %(thread)d', | |
level=logging.WARNING) | |
logging.debug('This message should go to the log file') | |
logging.info('I told ya!') | |
logging.warning('Watch out!') | |
logging.error('An error occured. Program has halt.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment