From 5e5b1bce3559a8e8efdf7582adbc45d58aa35e49 Mon Sep 17 00:00:00 2001 From: Luis Pater Date: Sun, 10 May 2026 15:28:49 +0800 Subject: [PATCH] feat(config): add detailed logging for home config changes - Introduced `logHomeConfigChanges` to compare old and new configs, logging detected differences. - Leveraged `diff.BuildConfigChangeDetails` for structured change detection. - Adjusted logging behavior to enable debug-level logs dynamically when required. --- sdk/cliproxy/service.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sdk/cliproxy/service.go b/sdk/cliproxy/service.go index 89a480b50..8685872e0 100644 --- a/sdk/cliproxy/service.go +++ b/sdk/cliproxy/service.go @@ -17,7 +17,9 @@ import ( "github.com/router-for-me/CLIProxyAPI/v7/internal/redisqueue" "github.com/router-for-me/CLIProxyAPI/v7/internal/registry" "github.com/router-for-me/CLIProxyAPI/v7/internal/runtime/executor" + "github.com/router-for-me/CLIProxyAPI/v7/internal/util" "github.com/router-for-me/CLIProxyAPI/v7/internal/watcher" + "github.com/router-for-me/CLIProxyAPI/v7/internal/watcher/diff" "github.com/router-for-me/CLIProxyAPI/v7/internal/wsrelay" sdkaccess "github.com/router-for-me/CLIProxyAPI/v7/sdk/access" sdkAuth "github.com/router-for-me/CLIProxyAPI/v7/sdk/auth" @@ -606,9 +608,30 @@ func (s *Service) applyHomeOverlay(remoteCfg *config.Config) { merged.Home = baseCfg.Home forceHomeRuntimeConfig(&merged) + logHomeConfigChanges(baseCfg, &merged) s.applyConfigUpdate(&merged) } +func logHomeConfigChanges(oldCfg, newCfg *config.Config) { + if oldCfg == nil || newCfg == nil || !newCfg.Home.Enabled || (!oldCfg.Debug && !newCfg.Debug) { + return + } + + details := diff.BuildConfigChangeDetails(oldCfg, newCfg) + if len(details) == 0 { + return + } + + if newCfg.Debug && !log.IsLevelEnabled(log.DebugLevel) { + util.SetLogLevel(newCfg) + } + + log.Debugf("home config changes detected:") + for _, detail := range details { + log.Debugf(" %s", detail) + } +} + func (s *Service) startHomeUsageForwarder(ctx context.Context, client *home.Client) { if s == nil || client == nil { return