mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-05-16 11:46:06 +08:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user