Add --debug-log flag

Add a `--debug-log` flag for specifying a path to write the debug logs
to for runc.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-08-04 12:36:53 -07:00
parent 5e75a12ec1
commit 5a3ebbdb1f
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)
}