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
1 changed files with 13 additions and 0 deletions

View File

@ -58,6 +58,11 @@ func main() {
Name: "debug",
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{
Name: "root",
Usage: "containerd state directory",
@ -88,6 +93,14 @@ func main() {
if context.GlobalBool("debug") {
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
}
app.Action = func(context *cli.Context) error {