summaryrefslogtreecommitdiffhomepage
path: root/runsc
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-02-27 10:05:46 -0800
committerShentubot <shentubot@google.com>2019-02-27 10:06:35 -0800
commit6df212b831dcc3350b7677423ec7835ed40b3f22 (patch)
tree278dad70f5a16efc0bf35d9eab060ef9cc10f0c7 /runsc
parentd516ee3312411c60630305cfaac6c5a0e21537e8 (diff)
Don't log twice to debug log when --log isn't set
PiperOrigin-RevId: 235940853 Change-Id: I9c5b4cf18b199fb74044a5edb131bfff59dec945
Diffstat (limited to 'runsc')
-rw-r--r--runsc/main.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/runsc/main.go b/runsc/main.go
index 472839bf0..4f89312b3 100644
--- a/runsc/main.go
+++ b/runsc/main.go
@@ -192,7 +192,13 @@ func main() {
cmd.Fatalf("error dup'ing fd %d to stderr: %v", f.Fd(), err)
}
- e = log.MultiEmitter{e, newEmitter(*debugLogFormat, f)}
+ if logFile == os.Stderr {
+ // Suppress logging to stderr when debug log is enabled. Otherwise all
+ // messages will be duplicated in the debug log (see Dup2() call above).
+ e = newEmitter(*debugLogFormat, f)
+ } else {
+ e = log.MultiEmitter{e, newEmitter(*debugLogFormat, f)}
+ }
} else if *debugLog != "" {
f, err := specutils.DebugLogFile(*debugLog, subcommand)
if err != nil {