Add log level parameter
This commit is contained in:
parent
8bffea0aea
commit
ae20a6d11d
18
main.go
18
main.go
@ -36,6 +36,24 @@ type CLI struct {
|
|||||||
Image ImageCmd `cmd:"" help:"manage images"`
|
Image ImageCmd `cmd:"" help:"manage images"`
|
||||||
|
|
||||||
Version VersionFlag `name:"version" help:"print version information and quit"`
|
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
|
type VersionFlag string
|
||||||
|
2
pew.go
2
pew.go
@ -50,7 +50,7 @@ type PewCmd struct {
|
|||||||
func (cmd PewCmd) Run(g *Globals) (err error) {
|
func (cmd PewCmd) Run(g *Globals) (err error) {
|
||||||
kcfg, err := config.ReadKernelConfig(g.Config.Kernels)
|
kcfg, err := config.ReadKernelConfig(g.Config.Kernels)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Debug().Err(err).Msg("read kernel config")
|
||||||
}
|
}
|
||||||
|
|
||||||
stop := time.Time{} // never stop
|
stop := time.Time{} // never stop
|
||||||
|
Loading…
Reference in New Issue
Block a user