From 5a3ebbdb1fd69245aa16652297d7ae18748a7ade Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 4 Aug 2015 12:36:53 -0700 Subject: [PATCH] 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 --- main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index e898c03fd..b71de2dfb 100644 --- a/main.go +++ b/main.go @@ -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) }