Browse Source

embed: use /dev/null to discard server logs

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
a31c38f3b0
2 changed files with 3 additions and 13 deletions
  1. 1 11
      embed/config.go
  2. 2 2
      embed/config_test.go

+ 1 - 11
embed/config.go

@@ -405,7 +405,6 @@ func (cfg *Config) setupLogging() error {
 			Encoding:      "json",
 			EncoderConfig: zap.NewProductionEncoderConfig(),
 		}
-		ignoreLog := false
 		switch cfg.LogOutput {
 		case DefaultLogOutput:
 			if syscall.Getppid() == 1 {
@@ -430,11 +429,6 @@ func (cfg *Config) setupLogging() error {
 			lcfg.OutputPaths = []string{"stdout"}
 			lcfg.ErrorOutputPaths = []string{"stdout"}
 
-		case "discard": // only for testing
-			lcfg.OutputPaths = []string{}
-			lcfg.ErrorOutputPaths = []string{}
-			ignoreLog = true
-
 		default:
 			lcfg.OutputPaths = []string{cfg.LogOutput}
 			lcfg.ErrorOutputPaths = []string{cfg.LogOutput}
@@ -446,11 +440,7 @@ func (cfg *Config) setupLogging() error {
 		}
 
 		var err error
-		if !ignoreLog {
-			cfg.logger, err = lcfg.Build()
-		} else {
-			cfg.logger = zap.NewNop()
-		}
+		cfg.logger, err = lcfg.Build()
 		if err != nil {
 			return err
 		}

+ 2 - 2
embed/config_test.go

@@ -41,7 +41,7 @@ func TestConfigFileOtherFields(t *testing.T) {
 		ptls,
 		true,
 		"zap",
-		"discard",
+		"/dev/null",
 		false,
 	}
 
@@ -157,7 +157,7 @@ func mustCreateCfgFile(t *testing.T, b []byte) *os.File {
 func TestAutoCompactionModeInvalid(t *testing.T) {
 	cfg := NewConfig()
 	cfg.Logger = "zap"
-	cfg.LogOutput = "discard"
+	cfg.LogOutput = "/dev/null"
 	cfg.Debug = false
 	cfg.AutoCompactionMode = "period"
 	err := cfg.Validate()