Skip to content

Instantly share code, notes, and snippets.

@khiemdoan
Created September 13, 2019 06:52
Show Gist options
  • Save khiemdoan/c4739b536dd2a03654a445929144f059 to your computer and use it in GitHub Desktop.
Save khiemdoan/c4739b536dd2a03654a445929144f059 to your computer and use it in GitHub Desktop.
import logging
import logging.handlers
from pathlib import Path
from utils import Filesystem
__author__ = 'KhiemDH'
__github__ = 'https://github.com/khiemdoan'
__email__ = 'doankhiem.crazy@gmail.com'
def setup():
parent = Path(__file__).parent
Filesystem.mkdirs(parent)
log_file = str(Path(parent, 'log.log').absolute())
handler = logging.handlers.RotatingFileHandler(log_file, maxBytes=2000000, backupCount=5, encoding='utf-8')
formater = logging.Formatter('%(asctime)s - %(module)s - %(funcName)s: [%(levelname)s] %(message)s')
handler.setFormatter(formater)
logger = logging.getLogger()
logger.addHandler(handler)
logger.setLevel(logging.INFO)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment