fix: load log configuration from config file#667
Open
jeengbe wants to merge 1 commit into
Open
Conversation
Signed-off-by: Jesper Engberg <jeengbe@gmail.com>
983b08d to
f292cc2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm relatively new to Go, so please bear with me :)
The default
logf.Logreturns adelegatingLogSinkwhose implementation can (crucially) only be overwritten once. So the first time the logger is configured with_ = setLogger(&opts, "", ""), that call only includes CLI flags, but not options loaded from the configuration file.Instead, this PR hard-wires the
setupLoglogger to usezap.New(zap.UseDevMode(true)), which ensures that all setup/teardown logs remain visible while allowing the later realsetLoggerto replace the remaining application loggers fromctrl.Log.This has two side effects:
setupLogexplicitly don't print logs beforesetLoggeris calledI don't see a clean way around that second catch-22. Given that the global delegating logger instance may only be rebound once and loading the configuration file itself may possibly emit logs (I did not find that it does, but it seems not to be prohibited_ from doing so), the only clean fix I see is to not use the global logger from the pre-configuration pass?