Skip to content

Instantly share code, notes, and snippets.

@luoyetx
Created August 3, 2017 12:02
Show Gist options
  • Save luoyetx/c0b5fc5ec6cdfb59d265af7cd53051f5 to your computer and use it in GitHub Desktop.
Save luoyetx/c0b5fc5ec6cdfb59d265af7cd53051f5 to your computer and use it in GitHub Desktop.
get logger in python
import logging
def get_logger(name=None):
"""return a logger
"""
logger = logging.getLogger(name)
logger.setLevel(logging.INFO)
sh = logging.StreamHandler()
sh.setLevel(logging.INFO)
formatter = logging.Formatter('[%(asctime)s][%(levelname)s] %(message)s')
sh.setFormatter(formatter)
logger.addHandler(sh)
return logger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment