Skip to content

Instantly share code, notes, and snippets.

@mattkohl
Created February 10, 2017 12:04
Show Gist options
  • Save mattkohl/b5c70ed0d284ed76746f7d702521ec99 to your computer and use it in GitHub Desktop.
Save mattkohl/b5c70ed0d284ed76746f7d702521ec99 to your computer and use it in GitHub Desktop.
Python logging recipe
import logging
logger = logging.getLogger()
handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
logger.debug("Testing, testing, 1, 2, 3")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment