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:
parent
5e75a12ec1
commit
5a3ebbdb1f
13
main.go
13
main.go
|
@ -48,6 +48,10 @@ func main() {
|
||||||
Name: "debug",
|
Name: "debug",
|
||||||
Usage: "enable debug output for logging",
|
Usage: "enable debug output for logging",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "log",
|
||||||
|
Usage: "set the log file path where internal debug information is written",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "root",
|
Name: "root",
|
||||||
Value: "/run/oci",
|
Value: "/run/oci",
|
||||||
|
@ -74,12 +78,17 @@ func main() {
|
||||||
if context.GlobalBool("debug") {
|
if context.GlobalBool("debug") {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to 'start' is no command is specified
|
// Default to 'start' is no command is specified
|
||||||
app.Action = startCommand.Action
|
app.Action = startCommand.Action
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue