# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   PythonProject_1
# FileName:      __init__.py
# Author:       H_M
# Datetime:     2024/9/4 18:23
# Description:
# ---------------------------------------------------------------------------
import logging
import os
import time


def log():
    logger = logging.getLogger()
    logger.level = logging.INFO
    log_name = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + '.log'
    log_dir = os.path.join(os.path.join(os.path.dirname(__file__), 'report'), 'log')
    file_path = os.path.join(log_dir, log_name)
    handle = logging.FileHandler(file_path, mode='a', encoding='utf-8')
    formatter = logging.Formatter('%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s -- %(name)s')
    handle.setFormatter(formatter)
    logger.addHandler(handle)
    return logger


log = log()

