kpod: make --debug work

The --debug flag is a global CLI flag, so parse it like one.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai 2017-08-17 11:13:00 -04:00
parent f82fe5691a
commit 05985ff2f7
2 changed files with 7 additions and 5 deletions

View file

@ -7,7 +7,6 @@ import (
"github.com/containers/storage"
"github.com/fatih/camelcase"
"github.com/kubernetes-incubator/cri-o/libkpod"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@ -50,9 +49,6 @@ func getConfig(c *cli.Context) (*libkpod.Config, error) {
config.StorageOptions = opts
}
}
if c.Bool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
if c.GlobalIsSet("runtime") {
config.Runtime = c.GlobalString("runtime")
}

View file

@ -15,7 +15,6 @@ func main() {
if reexec.Init() {
return
}
logrus.SetLevel(logrus.ErrorLevel)
app := cli.NewApp()
app.Name = "kpod"
@ -44,6 +43,13 @@ func main() {
statsCommand,
loadCommand,
}
app.Before = func(c *cli.Context) error {
logrus.SetLevel(logrus.ErrorLevel)
if c.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
return nil
}
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",