summaryrefslogtreecommitdiff
path: root/internal/runtimeconfig/store.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-26 07:52:08 +0300
committerPaul Buetow <paul@buetow.org>2025-09-26 07:52:08 +0300
commit2efcd2c4dda97831058851e8911281d5db5ce1c6 (patch)
treec59059cb4c781878f1291ca06fe1a215579a0fa8 /internal/runtimeconfig/store.go
parentd0330d02ff040326216ab940a767490cb2de09ce (diff)
Log config reload changes
Diffstat (limited to 'internal/runtimeconfig/store.go')
-rw-r--r--internal/runtimeconfig/store.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/internal/runtimeconfig/store.go b/internal/runtimeconfig/store.go
index e0a594c..3112951 100644
--- a/internal/runtimeconfig/store.go
+++ b/internal/runtimeconfig/store.go
@@ -85,7 +85,11 @@ func (s *Store) Reload(logger *log.Logger, opts appconfig.LoadOptions) ([]Change
if err := cfg.Validate(); err != nil {
return nil, err
}
- return s.Set(cfg), nil
+ changes := s.Set(cfg)
+ if logger != nil {
+ logger.Print(FormatSummary("Reloaded config", changes))
+ }
+ return changes, nil
}
// Diff computes a stable, sorted list of key/value changes between two configuration snapshots.
@@ -176,3 +180,16 @@ func stringifyValue(v reflect.Value) string {
return fmt.Sprint(v.Interface())
}
}
+
+// FormatSummary creates a human-readable summary for configuration changes.
+func FormatSummary(prefix string, changes []Change) string {
+ if len(changes) == 0 {
+ return fmt.Sprintf("%s (no changes detected).", prefix)
+ }
+ lines := make([]string, 0, len(changes)+1)
+ lines = append(lines, fmt.Sprintf("%s (%d changes):", prefix, len(changes)))
+ for _, ch := range changes {
+ lines = append(lines, fmt.Sprintf("- %s: %s → %s", ch.Key, ch.Old, ch.New))
+ }
+ return strings.Join(lines, "\n")
+}