feat: persist diagnostic logs with daily rotation and retention

This commit is contained in:
Ed1s0nZ
2026-09-08 14:41:46 +08:00
parent 6ad9ea2d13
commit 94cdf760af
10 changed files with 255 additions and 6 deletions
+6 -1
View File
@@ -25,7 +25,12 @@ func main() {
}
// 初始化日志(stdio 模式下使用 stderr 输出日志,避免干扰 JSON-RPC 通信)
log := logger.New(cfg.Log.Level, "stderr")
log := logger.New(cfg.Log.Level, "stderr", logger.DiagnosticOptions{
Dir: cfg.Log.DiagnosticDir,
Disabled: cfg.Log.DiagnosticDisabled,
RetentionDays: cfg.Log.DiagnosticRetentionDays,
})
defer log.Sync()
// 创建MCP服务器
mcpServer := mcp.NewServer(log.Logger)
+6 -1
View File
@@ -101,7 +101,12 @@ func main() {
}
// 初始化日志
log := logger.New(cfg.Log.Level, cfg.Log.Output)
log := logger.New(cfg.Log.Level, cfg.Log.Output, logger.DiagnosticOptions{
Dir: cfg.Log.DiagnosticDir,
Disabled: cfg.Log.DiagnosticDisabled,
RetentionDays: cfg.Log.DiagnosticRetentionDays,
})
defer log.Sync()
// 创建可取消的根 context,用于优雅关闭
ctx, cancel := context.WithCancel(context.Background())