Skip to content

Instantly share code, notes, and snippets.

@kdheepak
Created September 16, 2017 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdheepak/0499ec14e2d419717b447e1a88ce75f2 to your computer and use it in GitHub Desktop.
Save kdheepak/0499ec14e2d419717b447e1a88ce75f2 to your computer and use it in GitHub Desktop.
# Better Logging Format
## Author : Dheepak Krishnamurthy
## License : MIT
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# create formatter and add it to the handlers
formatter = logging.Formatter('%(asctime)s - [%(module)s(%(lineno)d)] - "%(name)s".%(levelname)s - %(message)s', "%Y-%m-%d %H:%M:%S")
ch.setFormatter(formatter)
# add the handlers to logger
logger.addHandler(ch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment