first commit

This commit is contained in:
2026-08-26 16:14:47 +08:00
commit 4bdbf31b3e
10 changed files with 763 additions and 0 deletions

29
utils/__init__.py Normal file
View File

@@ -0,0 +1,29 @@
"""
通用工具模块
"""
import logging
from datetime import datetime
def get_logger(name: str) -> logging.Logger:
"""创建仅输出到控制台的 logger"""
logger = logging.getLogger(name)
if not logger.handlers:
logger.setLevel(logging.INFO)
fmt = logging.Formatter("[%(asctime)s] %(name)s %(levelname)s - %(message)s")
sh = logging.StreamHandler()
sh.setFormatter(fmt)
logger.addHandler(sh)
return logger
def now_str(fmt: str = "%Y%m%d%H%M") -> str:
"""返回当前时间字符串,用于文件命名"""
return datetime.now().strftime(fmt)
# 注意:该导入必须放在 get_logger/now_str 定义之后——
# notify 模块内部通过 from . import get_logger 引用本包,
# 若放在定义之前会形成循环导入utils → notify → utils
from .notify import show_warning_countdown