opsdis / aci-exporter

A Cisco ACI Prometheus exporter written in Go
https://www.opsdis.com
GNU General Public License v3.0
47 stars 16 forks source link

loglevel is not set if passed from config File #64

Closed camrossi closed 4 months ago

camrossi commented 4 months ago

The log level in the config file is never read it only works if you set it as a flag.

As a quick fix I just added this after err := viper.ReadInConfig() and that fixed it

    ll := viper.GetString("loglevel")
    if ll != "" {
        level, err := log.ParseLevel(ll)
        if err != nil {
            log.Error(fmt.Sprintf("Not supported log level - %s", err))
            os.Exit(1)
        }
        log.SetLevel(level)
    }

Same thing for the config_dir

thenodon commented 4 months ago

Fixed in commit 82e7902. Will check if any of the loglevel, logformat, logfile was set on command line, if not read from config if set else default. Command line will always have highest precedence.