Skip to content

Instantly share code, notes, and snippets.

@rcastill
Created July 29, 2019 14:43
Show Gist options
  • Save rcastill/863268887214c3ca8d57e5d026084dd1 to your computer and use it in GitHub Desktop.
Save rcastill/863268887214c3ca8d57e5d026084dd1 to your computer and use it in GitHub Desktop.
Logger setup
# call once per file then retrieve with logging.getLogger(__file__)
import logging
def setup_logger(level):
log = logging.getLogger(__file__)
handler = logging.StreamHandler()
formatter = logging.Formatter(f'%(asctime)-15s {__file__} %(message)s')
handler.setFormatter(formatter)
log.addHandler(handler)
log.setLevel(level)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment