cfg: respect VOUCH_LOGLEVEL when no config file value is set#610
cfg: respect VOUCH_LOGLEVEL when no config file value is set#610c-tonneslan wants to merge 1 commit into
Conversation
Logging.configure() reset Cfg.LogLevel back to the default whenever viper.IsSet on the config-file key was false. envconfig writes the env-var value straight into Cfg.LogLevel and never goes through viper, so a user who set VOUCH_LOGLEVEL=debug without also putting logLevel in the config file always ended up back on info. Also check the matching env var before overriding so an env-only configuration is honored. The config-file path still wins when both are present, matching the documented precedence. Fixes vouch#540. Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
|
@c-tonneslan very much appreciate the contribution. Regarding...
Please take a look at... Line 175 in b683f60 The ENV var should take precedence. |
|
Good catch, sorry about that. You're right, the documented precedence is env > config and the actual order in The line I wrote in the PR description ("config-file path still wins when both are present") was backwards. Want me to amend the commit message or push a description-only fixup? |
Fixes #540.
`Logging.configure()` reset `Cfg.LogLevel` back to the default whenever `viper.IsSet` on the config-file key was false. `envconfig` (which is what reads `VOUCH_LOGLEVEL`) writes straight into `Cfg.LogLevel` and never goes through viper, so a user who set `VOUCH_LOGLEVEL=debug` without also putting `logLevel` in the config file always ended up back on info.
Also check the matching env var before clobbering the value, so an env-only configuration is honored. The config-file path still wins when both are present, matching the documented precedence.