initialize the log file before reporting config errors#1426
Merged
Conversation
Member
|
This is a nice improvement! Thank you Alison! |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Further to the discussion in #1413 here is change to the way we load the config file to first initialize the log file before reporting any errors in the config. This will hopefully make it more obvious to people who are running in an automated setup (i.e. Windows or systemd service) why something went wrong after an upgrade to an incompatible version, since normal output to stderr might otherwise get lost.
Here is the output of a manual test to show how it works:
Note that all errors returned during config will result in a fatal log due to code inside main.go (see https://github.com/alisonatwork/dnscrypt-proxy/blob/master/dnscrypt-proxy/main.go#L127) so even very aggressive log levels should still log this kind of failure to the log file or syslog.
To try make the behavior of all config errors resulting in a fatal log more clear to developers, I added a second commit which makes all of the fatal logs just return an error. There is an alternative option, which would be to replace all the "return error" lines with a fatal log. Personally I prefer returning an error, but I don't care too much either way, the main point here is to make all of them consistent.