diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-10-11 14:28:15 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-10-11 14:29:37 -0700 |
commit | e68d86e1bd47f7905e4452f7ce0e04e683561f85 (patch) | |
tree | f5e9ff902d3efbee1c33c9f2d5064f57cde977d2 /runsc/main.go | |
parent | 96c68b36f67355295339e8039712b28d272e083e (diff) |
Make debug log file name configurable
This is a breaking change if you're using --debug-log-dir.
The fix is to replace it with --debug-log and add a '/' at
the end:
--debug-log-dir=/tmp/runsc ==> --debug-log=/tmp/runsc/
PiperOrigin-RevId: 216761212
Change-Id: I244270a0a522298c48115719fa08dad55e34ade1
Diffstat (limited to 'runsc/main.go')
-rw-r--r-- | runsc/main.go | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/runsc/main.go b/runsc/main.go index 16d30f7a0..27aec1cd9 100644 --- a/runsc/main.go +++ b/runsc/main.go @@ -45,10 +45,10 @@ var ( // system that are not covered by the runtime spec. // Debugging flags. - debugLogDir = flag.String("debug-log-dir", "", "additional location for logs. It creates individual log files per command") - logPackets = flag.Bool("log-packets", false, "enable network packet logging") - logFD = flag.Int("log-fd", -1, "file descriptor to log to. If set, the 'log' flag is ignored.") - debugLogFD = flag.Int("debug-log-fd", -1, "file descriptor to write debug logs to. If set, the 'debug-log-dir' flag is ignored.") + debugLog = flag.String("debug-log", "", "additional location for logs. If it ends with '/', log files are created inside the directory with default names. The following variables are available: %TIMESTAMP%, %COMMAND%.") + logPackets = flag.Bool("log-packets", false, "enable network packet logging") + logFD = flag.Int("log-fd", -1, "file descriptor to log to. If set, the 'log' flag is ignored.") + debugLogFD = flag.Int("debug-log-fd", -1, "file descriptor to write debug logs to. If set, the 'debug-log-dir' flag is ignored.") // Debugging flags: strace related strace = flag.Bool("strace", false, "enable strace") @@ -131,7 +131,7 @@ func main() { Debug: *debug, LogFilename: *logFilename, LogFormat: *logFormat, - DebugLogDir: *debugLogDir, + DebugLog: *debugLog, FileAccess: fsAccess, Overlay: *overlay, Network: netType, @@ -195,13 +195,10 @@ func main() { } e = log.MultiEmitter{e, log.GoogleEmitter{&log.Writer{Next: f}}} - } else if *debugLogDir != "" { - if err := os.MkdirAll(*debugLogDir, 0775); err != nil { - cmd.Fatalf("error creating dir %q: %v", *debugLogDir, err) - } - f, err := specutils.DebugLogFile(*debugLogDir, subcommand) + } else if *debugLog != "" { + f, err := specutils.DebugLogFile(*debugLog, subcommand) if err != nil { - cmd.Fatalf("error opening debug log file in %q: %v", *debugLogDir, err) + cmd.Fatalf("error opening debug log file in %q: %v", *debugLog, err) } e = log.MultiEmitter{e, log.GoogleEmitter{&log.Writer{Next: f}}} } |