Use console logger instead of JSON output (#1)

Co-authored-by: Lauris BH <lauris@nix.lv>
Reviewed-on: https://codeberg.org/woodpecker-plugins/go-plugin/pulls/1
This commit is contained in:
Lauris BH 2023-01-09 01:17:04 +00:00
parent 60d32ee4ae
commit e5ca84b806

View File

@ -15,6 +15,8 @@
package plugin
import (
"os"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
@ -39,6 +41,7 @@ func SetupConsoleLogger(c *cli.Context) error {
log.Fatal().Msgf("unknown logging level: %s", level)
}
zerolog.SetGlobalLevel(lvl)
log.Logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stdout}).With().Timestamp().Logger()
if zerolog.GlobalLevel() <= zerolog.DebugLevel {
log.Logger = log.With().Caller().Logger()
log.Log().Msgf("LogLevel = %s", zerolog.GlobalLevel().String())