Browse Source

embed: error when different values are specified in "--log-output"

"--log-output default,a.log" should error out when etcd
runs as a systemd unit. We expect 'default' to be overridden
explicitly.

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
b6578c8f4d
1 changed files with 8 additions and 0 deletions
  1. 8 0
      embed/config.go

+ 8 - 0
embed/config.go

@@ -581,6 +581,14 @@ func (cfg *Config) setupLogging() error {
 				return err
 			}
 		} else {
+			if len(cfg.LogOutputs) > 1 {
+				for _, v := range cfg.LogOutputs {
+					if v != DefaultLogOutput {
+						return fmt.Errorf("running as a systemd unit but other '--log-output' values (%q) are configured with 'default'; override 'default' value with something else", cfg.LogOutputs)
+					}
+				}
+			}
+
 			// use stderr as fallback
 			syncer := getZapWriteSyncer()
 			lvl := zap.NewAtomicLevelAt(zap.InfoLevel)