mirror of https://github.com/docker/docs.git
Merge pull request #270 from aluzzardi/loglevel
Replace --debug with --log-level
This commit is contained in:
commit
29bbf0fb27
17
main.go
17
main.go
|
@ -30,14 +30,29 @@ func main() {
|
|||
Usage: "debug mode",
|
||||
EnvVar: "DEBUG",
|
||||
},
|
||||
|
||||
cli.StringFlag{
|
||||
Name: "log-level, l",
|
||||
Value: "info",
|
||||
Usage: fmt.Sprintf("Log level (options: debug, info, warn, error, fatal, panic)"),
|
||||
},
|
||||
}
|
||||
|
||||
// logs
|
||||
app.Before = func(c *cli.Context) error {
|
||||
log.SetOutput(os.Stderr)
|
||||
if c.Bool("debug") {
|
||||
level, err := log.ParseLevel(c.String("log-level"))
|
||||
if err != nil {
|
||||
log.Fatalf(err.Error())
|
||||
}
|
||||
log.SetLevel(level)
|
||||
|
||||
// If a log level wasn't specified and we are running in debug mode,
|
||||
// enforce log-level=debug.
|
||||
if !c.IsSet("log-level") && !c.IsSet("l") && c.Bool("debug") {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue