(message)
| 61 | } |
| 62 | |
| 63 | def 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 | |
| 84 | from llm_config import load_llm_config # 统一配置加载(环境变量优先) |
| 85 |
no outgoing calls
no test coverage detected