Created
July 20, 2017 03:18
-
-
Save edsion1107/7db6716b34e88b043e098d0968ad32ab to your computer and use it in GitHub Desktop.
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
import os | |
import logging | |
from logging.handlers import RotatingFileHandler | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) | |
fmt = logging.Formatter("%(asctime)s %(levelname)-7s %(module)10s:%(lineno)-4s %(message)s", "%H:%M:%S") | |
sh = logging.StreamHandler() | |
sh.setFormatter(fmt) | |
sh.setLevel(logging.INFO) | |
fmt = logging.Formatter("%(asctime)s %(levelname)-7s - %(module)10s:%(lineno)-5s - %(message)s", "%Y%m%d-%H:%M:%S") | |
fh = RotatingFileHandler(filename=os.path.join(os.path.dirname(__file__), 'CI.log'), maxBytes=1024 * 1024, | |
backupCount=5, encoding='utf-8') | |
fh.setFormatter(fmt) | |
fh.setLevel(logging.DEBUG) | |
logger.addHandler(sh) | |
logger.addHandler(fh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment