Merge pull request #503 from jmzwcn/master

Allow specifying the log level
This commit is contained in:
Phil Estes 2017-02-10 12:35:14 -08:00 committed by GitHub
commit 43e42b4222

View file

@ -58,6 +58,11 @@ func main() {
Name: "debug", Name: "debug",
Usage: "enable debug output in logs", Usage: "enable debug output in logs",
}, },
cli.StringFlag{
Name: "log-level",
Usage: "Set the logging level [debug, info, warn, error, fatal, panic]",
Value: "info",
},
cli.StringFlag{ cli.StringFlag{
Name: "root", Name: "root",
Usage: "containerd state directory", Usage: "containerd state directory",
@ -88,6 +93,14 @@ func main() {
if context.GlobalBool("debug") { if context.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel) logrus.SetLevel(logrus.DebugLevel)
} }
if logLevel := context.GlobalString("log-level"); logLevel != "" {
lvl, err := logrus.ParseLevel(logLevel)
if err != nil {
lvl = logrus.InfoLevel
fmt.Fprintf(os.Stderr, "Unable to parse logging level: %s\n, and being defaulted to info", logLevel)
}
logrus.SetLevel(lvl)
}
return nil return nil
} }
app.Action = func(context *cli.Context) error { app.Action = func(context *cli.Context) error {