From 7715b93eca57c1fa51afbd1d634b1f3c3576647f Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 21 May 2026 17:48:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(manage=5Flogs):=20=E4=BF=AE=E5=A4=8D=20douy?= =?UTF-8?q?in=5Flogging=20=E6=8B=86=E5=88=86=E5=90=8E=E7=9A=84=20import=20?= =?UTF-8?q?=E5=9B=9E=E5=BD=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit douyin/logging/douyin_logging.py 在 e35e8a8 commit 拆分为子包后, 原文件改成 re-export shim,不再"恰好"暴露 module-level 的 path_config 和全局变量 _log_monitor。 bin/manage_logs.py 之前依赖这两个间接 import: from douyin.logging.douyin_logging import path_config # 副作用 from douyin.logging.douyin_logging import _log_monitor # 全局变量 修复: - path_config 改为直接从源头导入:from douyin.core import path_config - _log_monitor 改为从子包内部状态读取: from douyin.logging.douyin_logging_pkg import _common as _logging_state _log_monitor = _logging_state._log_monitor 回归: - bin/manage_logs.py --help / monitor / stats 三个子命令全部正常 - pytest 353 passed / 1 skipped 不变 Co-Authored-By: Claude Opus 4.7 --- bin/manage_logs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/manage_logs.py b/bin/manage_logs.py index c5b186f..40c0e54 100644 --- a/bin/manage_logs.py +++ b/bin/manage_logs.py @@ -30,11 +30,11 @@ from typing import Dict, Any # 添加项目根到 sys.path(从 bin/ 目录运行时需要) sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from douyin.core import path_config from douyin.logging.douyin_logging import ( cleanup_old_logs, compress_log_file, get_log_stats, - path_config ) @@ -178,7 +178,8 @@ def show_monitor_status() -> None: """显示监控器状态""" print("\n=== 日志监控状态 ===") - from douyin.logging.douyin_logging import _log_monitor + from douyin.logging.douyin_logging_pkg import _common as _logging_state + _log_monitor = _logging_state._log_monitor if _log_monitor and _log_monitor._running: print("状态: 运行中")