From 2efcd2c4dda97831058851e8911281d5db5ce1c6 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 26 Sep 2025 07:52:08 +0300 Subject: Log config reload changes --- internal/runtimeconfig/store.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'internal/runtimeconfig/store.go') 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") +} -- cgit v1.2.3