From cdc71ae38e2da0b917bd7ed716cb78a6a52acaea Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Thu, 2 Nov 2017 14:32:20 -0700 Subject: [PATCH 1/2] embed: NewConfig sets LogOutput to "default" Otherwise, embedded etcd will panic in SetupLogging Signed-off-by: Gyu-Ho Lee --- embed/config.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/embed/config.go b/embed/config.go index d223b6696..096128cf1 100644 --- a/embed/config.go +++ b/embed/config.go @@ -55,6 +55,8 @@ const ( DefaultListenPeerURLs = "http://localhost:2380" DefaultListenClientURLs = "http://localhost:2379" + DefaultLogOutput = "default" + // maxElectionMs specifies the maximum value of election timeout. // More details are listed in ../Documentation/tuning.md#time-parameters. maxElectionMs = 50000 @@ -225,6 +227,7 @@ func NewConfig() *Config { ClusterState: ClusterStateFlagNew, InitialClusterToken: "etcd-cluster", StrictReconfigCheck: true, + LogOutput: DefaultLogOutput, Metrics: "basic", EnableV2: true, AuthToken: "simple", @@ -266,9 +269,9 @@ func (cfg *Config) SetupLogging() { capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stdout, cfg.Debug)) case "stderr": capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stderr, cfg.Debug)) - case "default": + case DefaultLogOutput: default: - plog.Panicf(`unknown log-output %q (only supports "default", "stdout", "stderr")`, cfg.LogOutput) + plog.Panicf(`unknown log-output %q (only supports %q, "stdout", "stderr")`, cfg.LogOutput, DefaultLogOutput) } } From adc3cea8cf81ccc5735133dea427cdaaaf5d67da Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Thu, 2 Nov 2017 14:43:06 -0700 Subject: [PATCH 2/2] etcdmain: use embed.DefaultLogOutput for flags Signed-off-by: Gyu-Ho Lee --- etcdmain/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etcdmain/config.go b/etcdmain/config.go index a186a3510..75ba112b3 100644 --- a/etcdmain/config.go +++ b/etcdmain/config.go @@ -192,7 +192,7 @@ func newConfig() *config { // logging fs.BoolVar(&cfg.Debug, "debug", false, "Enable debug-level logging for etcd.") fs.StringVar(&cfg.LogPkgLevels, "log-package-levels", "", "Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG').") - fs.StringVar(&cfg.LogOutput, "log-output", "default", "Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd.") + fs.StringVar(&cfg.LogOutput, "log-output", embed.DefaultLogOutput, "Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd.") // unsafe fs.BoolVar(&cfg.ForceNewCluster, "force-new-cluster", false, "Force to create a new one member cluster.")