Merge pull request #179 from crosbymichael/debug-log

Add --log flag
This commit is contained in:
Mrunal Patel 2015-08-28 13:12:50 -07:00
commit 9c1e298b0e
1 changed files with 11 additions and 2 deletions

13
main.go
View File

@ -48,6 +48,10 @@ func main() {
Name: "debug",
Usage: "enable debug output for logging",
},
cli.StringFlag{
Name: "log",
Usage: "set the log file path where internal debug information is written",
},
cli.StringFlag{
Name: "root",
Value: "/run/oci",
@ -74,12 +78,17 @@ func main() {
if context.GlobalBool("debug") {
logrus.SetLevel(logrus.DebugLevel)
}
if path := context.GlobalString("log"); path != "" {
f, err := os.Create(path)
if err != nil {
return err
}
logrus.SetOutput(f)
}
return nil
}
// Default to 'start' is no command is specified
app.Action = startCommand.Action
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}