Set default logging value of cli to info (#871)

This commit is contained in:
mscherer 2022-04-05 14:10:10 +02:00 committed by GitHub
parent c310363c99
commit cddc54bae4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View file

@ -51,6 +51,7 @@ var GlobalFlags = []cli.Flag{
EnvVars: []string{"WOODPECKER_LOG_LEVEL"},
Name: "log-level",
Usage: "set logging level",
Value: "info",
},
}

View file

@ -7,14 +7,12 @@ import (
)
func SetupConsoleLogger(c *cli.Context) error {
if c.IsSet("log-level") {
level := c.String("log-level")
lvl, err := zerolog.ParseLevel(level)
if err != nil {
log.Fatal().Msgf("unknown logging level: %s", level)
}
zerolog.SetGlobalLevel(lvl)
level := c.String("log-level")
lvl, err := zerolog.ParseLevel(level)
if err != nil {
log.Fatal().Msgf("unknown logging level: %s", level)
}
zerolog.SetGlobalLevel(lvl)
if zerolog.GlobalLevel() <= zerolog.DebugLevel {
log.Logger = log.With().Caller().Logger()
log.Log().Msgf("LogLevel = %s", zerolog.GlobalLevel().String())