Created
May 31, 2019 10:27
-
-
Save yiidtw/367294c1d3ac7f03dce6f1350155455c to your computer and use it in GitHub Desktop.
python logging snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3-aisoc | |
# -*- coding: utf-8 -*- | |
import logging | |
import sys | |
# set formatter | |
logging_formatter = logging.Formatter(' %(levelname)s %(asctime)s %(message)s', "%Y-%m-%d %H:%M:%S") | |
# set handler | |
logging_handler = logging.StreamHandler(sys.stdout) | |
logging_handler.setFormatter(logging_formatter) | |
# get logger | |
logger = logging.getLogger() | |
logger.addHandler(logging_handler) | |
logger.setLevel(logging.INFO) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment