feat: implement logging service with file output

- setup_logging() creates logs/ dir and writes timestamped log file
- format: asctime name levelname message
- falls back to console-only if log dir is not writable
- main.py now calls setup_logging() at startup and logs app name/version

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-15 16:33:33 +08:00
co-authored by Claude Sonnet 4.6
parent 7d941a03aa
commit 24d43db434
3 changed files with 60 additions and 15 deletions
+9 -9
View File
@@ -64,18 +64,18 @@
任务:
- [ ] 先读取 `src/services/log_service.py` 现有内容
- [ ] 完善 `src/services/log_service.py`
- [ ] 启动时创建 `logs/` 目录
- [ ] 日志文件按启动时间或日期命名
- [ ] 日志格式包含时间、模块、级别、消息
- [ ] 在 `src/main.py` 中初始化日志
- [x] 先读取 `src/services/log_service.py` 现有内容
- [x] 完善 `src/services/log_service.py`
- [x] 启动时创建 `logs/` 目录
- [x] 日志文件按启动时间或日期命名
- [x] 日志格式包含时间、模块、级别、消息
- [x] 在 `src/main.py` 中初始化日志
验收:
- [ ] 启动程序后生成日志文件
- [ ] 程序启动信息写入日志
- [ ] 不使用 `print` 作为正式日志
- [x] 启动程序后生成日志文件
- [x] 程序启动信息写入日志
- [x] 不使用 `print` 作为正式日志
### 1.2 路径与资源服务