mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
embed: use /dev/null to discard server logs
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
0e4c8dcedc
commit
a31c38f3b0
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user