写入日志到项目根目录的 log.txt
(message)
| 24 | sys.path.append(PROJECT_ROOT) |
| 25 | |
| 26 | def write_log(message): |
| 27 | """写入日志到项目根目录的 log.txt""" |
| 28 | try: |
| 29 | log_file = Path(PROJECT_ROOT) / "log.txt" |
| 30 | with open(log_file, "a", encoding="utf-8") as f: |
| 31 | f.write(f"[{threading.current_thread().name}] {message}\n") |
| 32 | except Exception as e: |
| 33 | print(f"日志写入失败:{e}") |
| 34 | |
| 35 | # 配置日志输出到标准输出 |
| 36 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', stream=sys.stdout) |
no outgoing calls
no test coverage detected