preserve simple and detail logs
This commit is contained in:
1 parent
f07fbb305b
commit
5e2ca0587b
4 files changed
+190
-62
No files matched your search
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from types import SimpleNamespace
|
||||
|
||||
from douyin.logging.douyin_logging_wrapper_pkg.enhanced import enhanced_log_kv
|
||||
@@ -168,3 +169,45 @@ def test_simple_suppresses_ocr_summary_and_validation_noise(capsys):
|
||||
)
|
||||
|
||||
assert capsys.readouterr().out == ""
|
||||
|
||||
|
||||
def test_enhanced_log_preserves_simple_and_detail_files(monkeypatch, tmp_path):
|
||||
import douyin.core.path_config as path_config
|
||||
|
||||
config_path = tmp_path / "config.json"
|
||||
config_path.write_text(
|
||||
json.dumps({"logging": {"log_format_mode": "simple"}}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setattr(path_config, "get_config_path", lambda: str(config_path))
|
||||
monkeypatch.setattr(
|
||||
path_config, "get_logs_dir", lambda: str(tmp_path)
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
path_config, "get_actions_log_path", lambda: str(tmp_path / "actions.log")
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
path_config, "get_simple_log_path", lambda: str(tmp_path / "simple.log")
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
path_config, "get_detail_log_path", lambda: str(tmp_path / "detail.log")
|
||||
)
|
||||
|
||||
analyser = _analyser()
|
||||
enhanced_log_kv(analyser, "福袋详情", "OCR摘要", log_type="OCR_SUMMARY", total_ms=1234.5)
|
||||
config_path.write_text(
|
||||
json.dumps({"logging": {"log_format_mode": "detailed"}}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
enhanced_log_kv(analyser, "福袋详情", "OCR摘要2", log_type="OCR_SUMMARY", total_ms=2345.6)
|
||||
|
||||
simple_log = next(tmp_path.glob("simple_*.log"))
|
||||
detail_log = next(tmp_path.glob("detail_*.log"))
|
||||
assert simple_log.exists()
|
||||
assert detail_log.exists()
|
||||
simple_text = simple_log.read_text(encoding="utf-8-sig")
|
||||
detail_text = detail_log.read_text(encoding="utf-8-sig")
|
||||
assert "OCR摘要" in simple_text
|
||||
assert "OCR摘要2" in simple_text
|
||||
assert "total_ms=1234.50" in detail_text
|
||||
assert "total_ms=2345.60" in detail_text
|
||||
Reference in new issue
Block a user