mirror of
https://github.com/0-8-4/miui-auto-tasks.git
synced 2024-11-16 04:35:51 +00:00
chore: 更新日志收集方法 (#203)
* fix: 修复无法构建docker镜像的问题 * Update Dockerfile * chore: 更新日志收集方法 * chore: 遵守代码规范 * chore: update issue templates
This commit is contained in:
parent
137b9afb22
commit
2bf3fb71b3
3
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
3
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -1,6 +1,6 @@
|
||||
name: 问题反馈
|
||||
description: Create a report to help us improve
|
||||
title: "[Bug] "
|
||||
title: "[Bug] 请在这块简要说明问题,否则该issue将会被关闭"
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
@ -77,6 +77,7 @@ body:
|
||||
label: MIUITask Log
|
||||
description: |
|
||||
在下方附上 MIUITask 输出日志 / MIUItask Log
|
||||
不上传log该issue将会被关闭
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@ -1,6 +1,6 @@
|
||||
name: 功能请求
|
||||
description: Suggest an idea for this project
|
||||
title: "[Feature] "
|
||||
title: "[Feature] 请在这块简要说明需求,否则该issue将会被关闭"
|
||||
labels: [enhancement]
|
||||
body:
|
||||
- type: markdown
|
||||
|
@ -8,7 +8,7 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
from utils.api.login import Login
|
||||
from utils.api.sign import BaseSign
|
||||
from utils.config import ConfigManager
|
||||
from utils.logger import get_message, log
|
||||
from utils.logger import InterceptHandler, log
|
||||
from utils.request import notify_me
|
||||
from utils.system_info import print_info
|
||||
from utils.utils import get_token
|
||||
@ -38,7 +38,8 @@ async def main():
|
||||
log.error(f"未找到{task.name}任务")
|
||||
else:
|
||||
log.info(f"{task.name}任务已完成")
|
||||
notify_me(get_message())
|
||||
log.info("`任务执行完毕`")
|
||||
notify_me(InterceptHandler.message)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,34 +1,26 @@
|
||||
"""
|
||||
'''
|
||||
Date: 2023-11-12 14:05:06
|
||||
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
||||
LastEditTime: 2023-11-18 14:20:44
|
||||
"""
|
||||
LastEditTime: 2023-11-24 13:10:39
|
||||
'''
|
||||
import os
|
||||
import sys
|
||||
|
||||
from loguru import logger
|
||||
|
||||
MESSAGE = ""
|
||||
|
||||
class InterceptHandler:
|
||||
"""拦截器"""
|
||||
|
||||
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
|
||||
message = ""
|
||||
"""消息"""
|
||||
|
||||
def __init__(self, record: dict):
|
||||
self.write(record)
|
||||
|
||||
def get_message():
|
||||
"""
|
||||
说明:
|
||||
返回消息
|
||||
返回:
|
||||
收集到的消息
|
||||
"""
|
||||
global MESSAGE # pylint: disable=global-variable-not-assigned
|
||||
return MESSAGE
|
||||
|
||||
def write(self, record: dict):
|
||||
"""写入"""
|
||||
InterceptHandler.message += record.get('message')
|
||||
|
||||
path_log = os.path.join("logs", '日志文件.log')
|
||||
log = logger
|
||||
@ -37,7 +29,7 @@ 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)
|
||||
"<level>{message}</level>", filter=InterceptHandler)
|
||||
|
||||
log.add(path_log, level="DEBUG",
|
||||
format="{time:HH:mm:ss} - "
|
||||
|
Loading…
Reference in New Issue
Block a user