diff --git a/main.go b/main.go index e898c03f..b71de2df 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) }