Re-add support for --debug.

If --debug is set (or $DEBUG) and no log level was specified, enforce
log-level=debug.

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2015-01-21 17:38:54 -08:00
parent 5200e3e764
commit 8d3d71ba41
1 changed files with 13 additions and 0 deletions

13
main.go
View File

@ -25,6 +25,12 @@ func main() {
app.Email = ""
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "debug mode",
EnvVar: "DEBUG",
},
cli.StringFlag{
Name: "log-level, l",
Value: "info",
@ -40,6 +46,13 @@ func main() {
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
}