mirror of
https://github.com/0-8-4/miui-auto-tasks.git
synced 2024-11-24 09:15:48 +00:00
6ade926505
* add missing dependency: apscheduler fix some bugs in Dockerfile * 🔧 自动更新requirements * fix: 解决某些情况下不能正确生成、读取配置文件 update: 将python版本升级到3.12,迁移pydantic v2依赖 修改Dockerfile * 🔧 自动更新requirements * Pylint * Hadolint - DL3042 https://github.com/hadolint/hadolint/wiki/DL3042 --------- Co-authored-by: JaHIY <jaklsy@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Night-stars-1 <99261160+Night-stars-1@users.noreply.github.com>
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
"""
|
|
Date: 2023-11-12 14:05:06
|
|
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
|
LastEditTime: 2023-11-18 14:20:44
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
from loguru import logger
|
|
|
|
MESSAGE = ""
|
|
|
|
|
|
def log_filter(record: dict):
|
|
"""loguru过滤器"""
|
|
global MESSAGE # pylint: disable=global-statement
|
|
if record["level"].no >= 20:
|
|
MESSAGE += f"{record.get('message')}\n"
|
|
return True
|
|
|
|
|
|
def get_message():
|
|
"""
|
|
说明:
|
|
返回消息
|
|
返回:
|
|
收集到的消息
|
|
"""
|
|
global MESSAGE # pylint: disable=global-variable-not-assigned
|
|
return MESSAGE
|
|
|
|
|
|
path_log = os.path.join("logs", '日志文件.log')
|
|
log = logger
|
|
log.remove()
|
|
|
|
log.add(sys.stdout, level="INFO", colorize=True,
|
|
format="<cyan>{module}</cyan>.<cyan>{function}</cyan>"
|
|
":<cyan>{line}</cyan> - "
|
|
"<level>{message}</level>", filter=log_filter)
|
|
|
|
log.add(path_log, level="DEBUG",
|
|
format="{time:HH:mm:ss} - "
|
|
"{level}\t| "
|
|
"{module}.{function}:{line} - {message}",
|
|
rotation="1 days", enqueue=True, serialize=False, encoding="utf-8", retention="10 days")
|