diff --git a/main.go b/main.go index e7cdfc5..01b5367 100644 --- a/main.go +++ b/main.go @@ -36,6 +36,24 @@ type CLI struct { Image ImageCmd `cmd:"" help:"manage images"` Version VersionFlag `name:"version" help:"print version information and quit"` + + LogLevel LogLevelFlag `enum:"debug,info,warn,error" default:"info"` +} + +type LogLevelFlag string + +func (loglevel LogLevelFlag) AfterApply() error { + switch loglevel { + case "debug": + zerolog.SetGlobalLevel(zerolog.DebugLevel) + case "info": + zerolog.SetGlobalLevel(zerolog.InfoLevel) + case "warn": + zerolog.SetGlobalLevel(zerolog.WarnLevel) + case "error": + zerolog.SetGlobalLevel(zerolog.ErrorLevel) + } + return nil } type VersionFlag string diff --git a/pew.go b/pew.go index d18dc09..3c8add3 100644 --- a/pew.go +++ b/pew.go @@ -50,7 +50,7 @@ type PewCmd struct { func (cmd PewCmd) Run(g *Globals) (err error) { kcfg, err := config.ReadKernelConfig(g.Config.Kernels) if err != nil { - log.Print(err) + log.Debug().Err(err).Msg("read kernel config") } stop := time.Time{} // never stop