Merge pull request #503 from jmzwcn/master
Allow specifying the log level
This commit is contained in:
commit
43e42b4222
1 changed files with 13 additions and 0 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue