From cddc54bae4ab962646ebfeba2bd4815e700eec0c Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 5 Apr 2022 14:10:10 +0200 Subject: [PATCH] Set default logging value of cli to info (#871) --- cli/common/flags.go | 1 + cli/common/zerologger.go | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cli/common/flags.go b/cli/common/flags.go index b58cfc6c1..84225f4ee 100644 --- a/cli/common/flags.go +++ b/cli/common/flags.go @@ -51,6 +51,7 @@ var GlobalFlags = []cli.Flag{ EnvVars: []string{"WOODPECKER_LOG_LEVEL"}, Name: "log-level", Usage: "set logging level", + Value: "info", }, } diff --git a/cli/common/zerologger.go b/cli/common/zerologger.go index a1763c014..3f48da046 100644 --- a/cli/common/zerologger.go +++ b/cli/common/zerologger.go @@ -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())