# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test_58
# FileName:      log.py
# Author:       xxxxxxx
# Datetime:     2024/1/4 11:48
# Description:
# 
# ---------------------------------------------------------------------------
import logging


def log(filename):
    # 创建logger对象
    loger = logging.getLogger()
    # 创建文件的控制器
    handler = logging.FileHandler(filename, mode="a", encoding="utf-8")
    # 设置日志文件中内容的格式
    formatter = logging.Formatter('%(levelname)s--%(asctime)s--%(message)s')
    # 格式添加到文件的控制器中
    handler.setFormatter(formatter)
    # logger对象添加文件控制器
    loger.addHandler(handler)
    # 设置日志文件的级别
    loger.level = logging.INFO

    return loger
