import logging
import logging.handlers

def init_log():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    # ch = logging.StreamHandler()
    fh = logging.handlers.RotatingFileHandler("Log/log.log",mode="a",maxBytes = 100*1024, backupCount = 10, encoding='utf-8')
    formatter = logging.Formatter(
        "%(asctime)s - %(module)s - %(funcName)s - line:%(lineno)d - %(levelname)s -: %(message)s"
    )
    fh.setFormatter(formatter)
    logger.addHandler(fh)  # 将日志输出至文件
    return logger

logger = init_log()