mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
embed: rename "LogOutput" to "LogOutputs"
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
3ea7a5d0bd
commit
f99cb35d29
@ -265,13 +265,13 @@ type Config struct {
|
|||||||
// WARN: "capnslog" is being deprecated in v3.5.
|
// WARN: "capnslog" is being deprecated in v3.5.
|
||||||
Logger string `json:"logger"`
|
Logger string `json:"logger"`
|
||||||
|
|
||||||
// LogOutput is either:
|
// LogOutputs is either:
|
||||||
// - "default" as os.Stderr,
|
// - "default" as os.Stderr,
|
||||||
// - "stderr" as os.Stderr,
|
// - "stderr" as os.Stderr,
|
||||||
// - "stdout" as os.Stdout,
|
// - "stdout" as os.Stdout,
|
||||||
// - file path to append server logs to.
|
// - file path to append server logs to.
|
||||||
// It can be multiple when "Logger" is zap.
|
// It can be multiple when "Logger" is zap.
|
||||||
LogOutput []string `json:"log-output"`
|
LogOutputs []string `json:"log-output"`
|
||||||
// Debug is true, to enable debug level logging.
|
// Debug is true, to enable debug level logging.
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ func NewConfig() *Config {
|
|||||||
loggerMu: new(sync.RWMutex),
|
loggerMu: new(sync.RWMutex),
|
||||||
logger: nil,
|
logger: nil,
|
||||||
Logger: "capnslog",
|
Logger: "capnslog",
|
||||||
LogOutput: []string{DefaultLogOutput},
|
LogOutputs: []string{DefaultLogOutput},
|
||||||
Debug: false,
|
Debug: false,
|
||||||
LogPkgLevels: "",
|
LogPkgLevels: "",
|
||||||
}
|
}
|
||||||
@ -433,14 +433,14 @@ func (cfg *Config) setupLogging() error {
|
|||||||
repoLog.SetLogLevel(settings)
|
repoLog.SetLogLevel(settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(cfg.LogOutput) != 1 {
|
if len(cfg.LogOutputs) != 1 {
|
||||||
fmt.Printf("expected only 1 value in 'log-output', got %v\n", cfg.LogOutput)
|
fmt.Printf("expected only 1 value in 'log-output', got %v\n", cfg.LogOutputs)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
// capnslog initially SetFormatter(NewDefaultFormatter(os.Stderr))
|
// capnslog initially SetFormatter(NewDefaultFormatter(os.Stderr))
|
||||||
// where NewDefaultFormatter returns NewJournaldFormatter when syscall.Getppid() == 1
|
// where NewDefaultFormatter returns NewJournaldFormatter when syscall.Getppid() == 1
|
||||||
// specify 'stdout' or 'stderr' to skip journald logging even when running under systemd
|
// specify 'stdout' or 'stderr' to skip journald logging even when running under systemd
|
||||||
output := cfg.LogOutput[0]
|
output := cfg.LogOutputs[0]
|
||||||
switch output {
|
switch output {
|
||||||
case "stdout":
|
case "stdout":
|
||||||
capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stdout, cfg.Debug))
|
capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stdout, cfg.Debug))
|
||||||
@ -452,11 +452,11 @@ func (cfg *Config) setupLogging() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "zap":
|
case "zap":
|
||||||
if len(cfg.LogOutput) == 0 {
|
if len(cfg.LogOutputs) == 0 {
|
||||||
cfg.LogOutput = []string{DefaultLogOutput}
|
cfg.LogOutputs = []string{DefaultLogOutput}
|
||||||
}
|
}
|
||||||
if len(cfg.LogOutput) > 1 {
|
if len(cfg.LogOutputs) > 1 {
|
||||||
for _, v := range cfg.LogOutput {
|
for _, v := range cfg.LogOutputs {
|
||||||
if v == DefaultLogOutput {
|
if v == DefaultLogOutput {
|
||||||
panic(fmt.Errorf("multi logoutput for %q is not supported yet", DefaultLogOutput))
|
panic(fmt.Errorf("multi logoutput for %q is not supported yet", DefaultLogOutput))
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@ func (cfg *Config) setupLogging() error {
|
|||||||
}
|
}
|
||||||
outputPaths, errOutputPaths := make(map[string]struct{}), make(map[string]struct{})
|
outputPaths, errOutputPaths := make(map[string]struct{}), make(map[string]struct{})
|
||||||
isJournald := false
|
isJournald := false
|
||||||
for _, v := range cfg.LogOutput {
|
for _, v := range cfg.LogOutputs {
|
||||||
switch v {
|
switch v {
|
||||||
case DefaultLogOutput:
|
case DefaultLogOutput:
|
||||||
if syscall.Getppid() == 1 {
|
if syscall.Getppid() == 1 {
|
||||||
|
@ -312,7 +312,7 @@ func (cfg *config) configFromCmdLine() error {
|
|||||||
oss = append(oss, v)
|
oss = append(oss, v)
|
||||||
}
|
}
|
||||||
sort.Strings(oss)
|
sort.Strings(oss)
|
||||||
cfg.ec.LogOutput = oss
|
cfg.ec.LogOutputs = oss
|
||||||
|
|
||||||
cfg.ec.ClusterState = cfg.cf.clusterState.String()
|
cfg.ec.ClusterState = cfg.cf.clusterState.String()
|
||||||
cfg.cp.Fallback = cfg.cf.fallback.String()
|
cfg.cp.Fallback = cfg.cf.fallback.String()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user