-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: 修复无法构建docker镜像的问题 * Update Dockerfile * chore: 更新日志收集方法 * chore: 遵守代码规范 * chore: update issue templates
- Loading branch information
1 parent
137b9af
commit 2bf3fb7
Showing
4 changed files
with
19 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,26 @@ | ||
""" | ||
''' | ||
Date: 2023-11-12 14:05:06 | ||
LastEditors: Night-stars-1 [email protected] | ||
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 @@ def get_message(): | |
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} - " | ||
|