MCPcopy Create free account
hub / github.com/NatsUIJM/autoContents / write_log

Function write_log

mainprogress/determine_toc_levels.py:63–82  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

61}
62
63def write_log(message):
64 try:
65 from datetime import datetime
66 timestamp = datetime.now().strftime("%H:%M:%S")
67
68 # 优先写入 session 日志
69 base_dir = os.getenv("BASE_DIR")
70 if base_dir:
71 session_log = Path(base_dir) / "session.log"
72 session_log.parent.mkdir(parents=True, exist_ok=True)
73 with open(session_log, "a", encoding="utf-8") as f:
74 f.write(f"[{timestamp}] {message}\n")
75
76 # 同时写入全局日志(兼容 SSE)
77 project_root = Path(__file__).parent.parent
78 global_log = project_root / "log.txt"
79 with open(global_log, "a", encoding="utf-8") as f:
80 f.write(f"[{timestamp}] [Determine Level] {message}\n")
81 except Exception:
82 pass
83
84from llm_config import load_llm_config # 统一配置加载(环境变量优先)
85

Callers 5

parse_csv_responseFunction · 0.70
process_first_pageFunction · 0.70
process_level_asyncFunction · 0.70
post_process_levelsFunction · 0.70
run_batch_processingFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected