import configparser
import logging
from logging.handlers import RotatingFileHandler
config = configparser.ConfigParser()
config.read("config", encoding="utf-8")
def get_logger(config):
logger = logging.getLogger()
rotating_log_handler = RotatingFileHandler(filename=config["loggers"]["logfile"], maxBytes=1024*1024*int(config["loggers"]["logMaxSize"]), backupCount=config["loggers"]["logBackupCount"])
rotating_log_handler.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s-%(filename)s-[line:%(lineno)d]-%(levelname)s: %(message)s")
rotating_log_handler.setFormatter(formatter)
logger.addHandler(rotating_log_handler)
logger.setLevel(logging.DEBUG)
return logger