auto-sync: 2026-05-17 18:33:31
This commit is contained in:
+29
@@ -21,6 +21,35 @@ from src.utils import get_data_root
|
||||
|
||||
logger = logging.getLogger("moziplus-v2")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 日志配置:确保 PM2 能捕获所有命名空间日志
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_logging_configured = False
|
||||
|
||||
|
||||
def _setup_logging():
|
||||
"""配置 logging,把 moziplus-v2 命名空间接到 root handler"""
|
||||
global _logging_configured
|
||||
if _logging_configured:
|
||||
return
|
||||
_logging_configured = True
|
||||
# 确保 moziplus-v2 命名空间日志输出到 stderr(PM2 捕获)
|
||||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(logging.Formatter(
|
||||
"%(asctime)s %(levelname)s %(name)s: %(message)s",
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
))
|
||||
for name in ("moziplus-v2", "moziplus-v2.ticker", "moziplus-v2.spawner",
|
||||
"moziplus-v2.dispatcher", "moziplus-v2.counter"):
|
||||
lg = logging.getLogger(name)
|
||||
lg.setLevel(logging.INFO)
|
||||
lg.addHandler(handler)
|
||||
lg.propagate = False # 避免重复
|
||||
|
||||
|
||||
_setup_logging()
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 配置加载
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user