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",
|
Encoding: "json",
|
||||||
EncoderConfig: zap.NewProductionEncoderConfig(),
|
EncoderConfig: zap.NewProductionEncoderConfig(),
|
||||||
}
|
}
|
||||||
ignoreLog := false
|
|
||||||
switch cfg.LogOutput {
|
switch cfg.LogOutput {
|
||||||
case DefaultLogOutput:
|
case DefaultLogOutput:
|
||||||
if syscall.Getppid() == 1 {
|
if syscall.Getppid() == 1 {
|
||||||
@ -430,11 +429,6 @@ func (cfg *Config) setupLogging() error {
|
|||||||
lcfg.OutputPaths = []string{"stdout"}
|
lcfg.OutputPaths = []string{"stdout"}
|
||||||
lcfg.ErrorOutputPaths = []string{"stdout"}
|
lcfg.ErrorOutputPaths = []string{"stdout"}
|
||||||
|
|
||||||
case "discard": // only for testing
|
|
||||||
lcfg.OutputPaths = []string{}
|
|
||||||
lcfg.ErrorOutputPaths = []string{}
|
|
||||||
ignoreLog = true
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
lcfg.OutputPaths = []string{cfg.LogOutput}
|
lcfg.OutputPaths = []string{cfg.LogOutput}
|
||||||
lcfg.ErrorOutputPaths = []string{cfg.LogOutput}
|
lcfg.ErrorOutputPaths = []string{cfg.LogOutput}
|
||||||
@ -446,11 +440,7 @@ func (cfg *Config) setupLogging() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if !ignoreLog {
|
|
||||||
cfg.logger, err = lcfg.Build()
|
cfg.logger, err = lcfg.Build()
|
||||||
} else {
|
|
||||||
cfg.logger = zap.NewNop()
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ func TestConfigFileOtherFields(t *testing.T) {
|
|||||||
ptls,
|
ptls,
|
||||||
true,
|
true,
|
||||||
"zap",
|
"zap",
|
||||||
"discard",
|
"/dev/null",
|
||||||
false,
|
false,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ func mustCreateCfgFile(t *testing.T, b []byte) *os.File {
|
|||||||
func TestAutoCompactionModeInvalid(t *testing.T) {
|
func TestAutoCompactionModeInvalid(t *testing.T) {
|
||||||
cfg := NewConfig()
|
cfg := NewConfig()
|
||||||
cfg.Logger = "zap"
|
cfg.Logger = "zap"
|
||||||
cfg.LogOutput = "discard"
|
cfg.LogOutput = "/dev/null"
|
||||||
cfg.Debug = false
|
cfg.Debug = false
|
||||||
cfg.AutoCompactionMode = "period"
|
cfg.AutoCompactionMode = "period"
|
||||||
err := cfg.Validate()
|
err := cfg.Validate()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user