From a31c38f3b0040b0d7296576415d073c95cfd290b Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Tue, 17 Apr 2018 06:13:24 -0700 Subject: [PATCH] embed: use /dev/null to discard server logs Signed-off-by: Gyuho Lee --- embed/config.go | 12 +----------- embed/config_test.go | 4 ++-- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/embed/config.go b/embed/config.go index 2e958c2e9..55e6a746e 100644 --- a/embed/config.go +++ b/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 } diff --git a/embed/config_test.go b/embed/config_test.go index cfcf77ada..0012a28d2 100644 --- a/embed/config_test.go +++ b/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()