Created
January 20, 2020 20:09
-
-
Save mayaracsferreira/1a4ebcd0c90e4f2c1db3546373cd049b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 logging | |
import os | |
import time | |
class Logger: | |
FORMATSTR = '%(asctime)s\t| %(levelname)-6s | %(message)s' | |
TIMESTR = time.strftime("%Y%m%d") | |
def __init__(self, log_folder, log_file): | |
self.log_file = log_file | |
self.log_folder = log_folder | |
if not os.path.exists(log_folder): | |
os.makedirs(log_folder) | |
logging.basicConfig(filename='{}\\{}-{}.log'.format(self.log_folder,self.TIMESTR, self.log_file) , filemode='a', format=self.FORMATSTR, level=logging.INFO) | |
def info(self, msg): | |
logging.info(msg) | |
def error(self, msg): | |
logging.error(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment