Logger日志
# -*- coding: utf-8 -*-
"""
@Time : 2021/7/20 11:34
@Author : Little Duo
@File : LoggerUtil.py
"""
import time
import os
import sys
from loguru import logger
Log_DIR = 'log'
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
logFilePath = os.path.join(BASE_DIR, '{}/{}'.format(Log_DIR, f'{time.strftime("%Y-%m-%d")} Log.log'))
errorLogFilePath = os.path.join(BASE_DIR, '{}/{}'.format(Log_DIR, f'{time.strftime("%Y-%m-%d")} Error.log'))
logger.add(sys.stderr, filter="my_module")
logger.add(logFilePath, format="{level} {time} {message}", rotation="1 week", compression="zip", encoding='utf-8', level='INFO')
logger.add(errorLogFilePath, format="{level} {time} {message}", rotation="1 week", compression="zip", encoding='utf-8', level='ERROR')