Merge pull request #96 from dswarbrick/respect-log-level-flag

Instantiate logger after parsing log.level command-line flag
This commit is contained in:
Conrad Hoffmann 2022-01-11 20:32:31 +01:00 committed by GitHub
commit 83cf88dcc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import (
"os/signal"
"syscall"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
@ -48,8 +49,7 @@ var (
}
reloadCh chan chan error
promlogConfig = &promlog.Config{}
logger = promlog.New(promlogConfig)
logger log.Logger
)
func remoteIPMIHandler(w http.ResponseWriter, r *http.Request) {
@ -94,10 +94,12 @@ func updateConfiguration(w http.ResponseWriter, r *http.Request) {
}
func main() {
promlogConfig := &promlog.Config{}
flag.AddFlags(kingpin.CommandLine, promlogConfig)
kingpin.HelpFlag.Short('h')
kingpin.Version(version.Print("ipmi_exporter"))
kingpin.Parse()
logger = promlog.New(promlogConfig)
_ = level.Info(logger).Log("msg", "Starting ipmi_exporter", "version", version.Info())
// Bail early if the config is bad.