Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting log level via environment variables does not work #540

Open
shapirus opened this issue Aug 15, 2023 · 1 comment
Open

Setting log level via environment variables does not work #540

shapirus opened this issue Aug 15, 2023 · 1 comment

Comments

@shapirus
Copy link

No matter what value VOUCH_LOGLEVEL environment variable is set to, effective value always ends up being info.

Setting it via the config file, on the other hand, does work.

I believe it happens because of the following code in pkg/cfg/logging.go, func (logging) configure() {:

        // then we weren't configured via command line, check the config file
        if !viper.IsSet(Branding.LCName + ".logLevel") {
                // then we weren't configured via the config file, set the default
                Cfg.LogLevel = fmt.Sprintf("%s", Logging.DefaultLogLevel)
        }       

        if Cfg.LogLevel != Logging.AtomicLogLevel.Level().String() {
                // log.Errorf("Logging.configure() Logging.LogLevel %s Cfg.LogLevel %s", Logging.LogLeveLogging.String(), Cfg.LogLevel)
                Logging.setLogLevelString(Cfg.LogLevel)
        }       

As we can see, Cfg.LogLevel is forced to the default value, unless it is set in the config file, and, if I'm not mistaken, the environment variable never has a chance to take effect.

This was tested with quay.io/vouch/vouch-proxy:0.39. To be honest, I didn't try to set any values other than debug, but I don't think it would've changed anything.

@bnfinet
Copy link
Member

bnfinet commented Aug 22, 2023

yep, looks like a bug!

Thanks much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants