make gateway reload use new loglevel#2155
Conversation
|
The result is that a failed reload can still leave the process running with the new log level, even though the rest of the new configuration was not successfully applied. That breaks the current rollback semantics of the reload flow and can also make failures harder to diagnose:
I think the log level change should either: be applied only after the reload has succeeded, or save the previous logger level and restore it on every failure path |
done |
yinwm
left a comment
There was a problem hiding this comment.
Thanks for this PR! The goal of syncing log level during config reload is clear and much needed.
One blocking issue I'd like addressed before merge:
Thread safety on debug field — services.debug is a plain bool written in Run() (main goroutine) and read in handleConfigReload() (reload goroutine via channel/select). This is a data race that the Go race detector would flag. Since debug is a CLI flag that never changes after startup, I'd suggest passing it as a function parameter to executeReload → handleConfigReload instead of storing it in the shared services struct. This also makes the dependency explicit and easier to test.
A few non-blocking suggestions:
- Add a log line to confirm the level change (output before calling
SetLevelFromString, so it's visible regardless of the new level) - Consider moving the level update to the end of the reload flow, so reload-related info logs aren't suppressed mid-way
- A brief comment explaining that
debugmode permanently overrides config log level would help future maintainers
done |
yinwm
left a comment
There was a problem hiding this comment.
Looks good to me. This correctly fills the gap left by #1853 — applying the configured log level on config reload.
A couple of non-blocking suggestions:
- The log message "Log level changing from current to %q" could be more informative — consider logging the previous level if the logger exposes it.
- It'd be nice to have a test case for log level change on reload, but not blocking for this PR.
Nice touch placing the log level update at the end of reload to avoid suppressing reload-related logs.
📝 Description
make gateway reload use new loglevel
🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
📚 Technical Context (Skip for Docs)
🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
☑️ Checklist