Skip to content

fix: dynamic log level changes now affect existing loggers#914

Merged
mattisonchao merged 1 commit intomainfrom
fix/dynamic-log-level-changes
Feb 26, 2026
Merged

fix: dynamic log level changes now affect existing loggers#914
mattisonchao merged 1 commit intomainfrom
fix/dynamic-log-level-changes

Conversation

@mattisonchao
Copy link
Copy Markdown
Member

@mattisonchao mattisonchao commented Feb 26, 2026

Summary

  • Use a shared slog.LevelVar (atomic) instead of a concrete slog.Level when configuring the slog-zerolog handler, so all loggers (including derived ones from slog.With()) dynamically pick up level changes
  • Simplify ReconfigureLogger() to atomically update the shared level variable instead of recreating the entire handler
  • Add tests verifying derived loggers reflect dynamic level changes

Test plan

  • go test ./oxiad/common/logging/... — new tests pass
  • go test ./oxiad/dataserver/... — all pass
  • go test ./oxiad/coordinator/... — all pass
  • go test ./cmd/server/... — passes
  • Verify in a running instance that changing log level via config reload affects all component loggers

Previously, ReconfigureLogger() recreated the entire handler and called
slog.SetDefault(), but component loggers created earlier via slog.With()
still referenced the old handler with the old level. By using a shared
slog.LevelVar (atomic) passed to the handler, all existing loggers pick
up level changes immediately without handler recreation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mattisonchao mattisonchao self-assigned this Feb 26, 2026
@mattisonchao mattisonchao merged commit dd53f1e into main Feb 26, 2026
13 of 15 checks passed
@mattisonchao mattisonchao deleted the fix/dynamic-log-level-changes branch February 26, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant