fix(logs): 日志归拢 data/logs/ 并为桌面版 desktop.log 增加大小切割

- 新增 app/logfile.py attach_rotating_log: 统一 data/logs/ 子目录 + RotatingFileHandler + 旧位置日志一次性迁移 (目标已存在/被占用则跳过, 失败仅 warning 不阻断启动)
- desktop.py: desktop.log 由无限追加 FileHandler 改为 10MB×5 切割 (长期挂机不再无限增长); 失败页与错误提示的用户可见路径同步 data\logs\desktop.log
- main.py: backend.log 改用共享函数, 参数不变 (10MB×3), 目录随迁
- README/dev.ps1 排障路径同步; 新增 test_logging_setup.py 4 例 (迁移/冷启动/不覆盖/不可写容错)
This commit is contained in:
shy3130
2026-10-23 22:00:51 +08:00
parent 14391914e3
commit 5d6ac5c736
6 changed files with 160 additions and 45 deletions
+1 -1
View File
@@ -242,7 +242,7 @@ $BackendErrLog = Join-Path $LogDir 'backend.err.log'
$FrontendOutLog = Join-Path $LogDir 'frontend.out.log'
$FrontendErrLog = Join-Path $LogDir 'frontend.err.log'
# 每次启动重置本会话日志 (后端自身的 data/backend.log 已有轮转, 这里只放转发副本)
# 每次启动重置本会话日志 (后端自身的 data\logs\backend.log 已有轮转, 这里只放转发副本)
foreach ($f in @($BackendOutLog, $BackendErrLog, $FrontendOutLog, $FrontendErrLog)) {
Remove-Item $f -Force -ErrorAction SilentlyContinue
}