Skip to content

Instantly share code, notes, and snippets.

@ashishsinghucd
Created June 4, 2020 17:54
Show Gist options
  • Save ashishsinghucd/1eb7a404f47e5fc74567d51085faad6b to your computer and use it in GitHub Desktop.
Save ashishsinghucd/1eb7a404f47e5fc74567d51085faad6b to your computer and use it in GitHub Desktop.
How to use logging in python
logger = logging.getLogger(__name__)
handler = logging.StreamHandler()
logging_format = logging.Formatter('%(asctime)s %(name)s %(levelname)s - %(message)s')
handler.setFormatter(logging_format)
logger.setLevel(logging.DEBUG). # Do not use handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment