diff --git a/clientv3/snapshot/member_test.go b/clientv3/snapshot/member_test.go index a42066a56..04c9a2da1 100644 --- a/clientv3/snapshot/member_test.go +++ b/clientv3/snapshot/member_test.go @@ -65,7 +65,6 @@ func TestSnapshotV3RestoreMultiMemberAdd(t *testing.T) { cfg := embed.NewConfig() cfg.Logger = "zap" cfg.LogOutputs = []string{"/dev/null"} - cfg.Debug = false cfg.Name = "3" cfg.InitialClusterToken = testClusterTkn cfg.ClusterState = "existing" diff --git a/clientv3/snapshot/v3_snapshot_test.go b/clientv3/snapshot/v3_snapshot_test.go index 0a4c3096c..36eeac5bd 100644 --- a/clientv3/snapshot/v3_snapshot_test.go +++ b/clientv3/snapshot/v3_snapshot_test.go @@ -47,7 +47,6 @@ func TestSnapshotV3RestoreSingle(t *testing.T) { cfg := embed.NewConfig() cfg.Logger = "zap" cfg.LogOutputs = []string{"/dev/null"} - cfg.Debug = false cfg.Name = "s1" cfg.InitialClusterToken = testClusterTkn cfg.ClusterState = "existing" @@ -200,7 +199,6 @@ func createSnapshotFile(t *testing.T, kvs []kv) string { cfg := embed.NewConfig() cfg.Logger = "zap" cfg.LogOutputs = []string{"/dev/null"} - cfg.Debug = false cfg.Name = "default" cfg.ClusterState = "new" cfg.LCUrls, cfg.ACUrls = cURLs, cURLs @@ -267,7 +265,6 @@ func restoreCluster(t *testing.T, clusterN int, dbPath string) ( cfg := embed.NewConfig() cfg.Logger = "zap" cfg.LogOutputs = []string{"/dev/null"} - cfg.Debug = false cfg.Name = fmt.Sprintf("%d", i) cfg.InitialClusterToken = testClusterTkn cfg.ClusterState = "existing" diff --git a/embed/config.go b/embed/config.go index 2b44cf05d..dba3a867a 100644 --- a/embed/config.go +++ b/embed/config.go @@ -290,8 +290,8 @@ type Config struct { ListenMetricsUrls []url.URL ListenMetricsUrlsJSON string `json:"listen-metrics-urls"` - // Logger is logger options: "zap", "capnslog". - // WARN: "capnslog" is being deprecated in v3.5. + // Logger is logger options: currently only supports "zap". + // "capnslog" is removed in v3.5. Logger string `json:"logger"` // LogLevel configures log level. Only supports debug, info, warn, error, panic, or fatal. Default 'info'. LogLevel string `json:"log-level"` @@ -322,19 +322,6 @@ type Config struct { // EnableGRPCGateway is false to disable grpc gateway. EnableGRPCGateway bool `json:"enable-grpc-gateway"` - - // TO BE DEPRECATED - - // DeprecatedLogOutput is to be deprecated in v3.5. - // Just here for safe migration in v3.4. - DeprecatedLogOutput []string `json:"log-output"` - // Debug is true, to enable debug level logging. - // WARNING: to be deprecated in 3.5. Use "--log-level=debug" instead. - Debug bool `json:"debug"` - // LogPkgLevels is being deprecated in v3.5. - // Only valid if "logger" option is "capnslog". - // WARN: DO NOT USE THIS! - LogPkgLevels string `json:"log-package-levels"` } // configYAML holds the config suitable for yaml parsing @@ -411,14 +398,11 @@ func NewConfig() *Config { PreVote: false, // TODO: enable by default in v3.5 - loggerMu: new(sync.RWMutex), - logger: nil, - Logger: "capnslog", - DeprecatedLogOutput: []string{DefaultLogOutput}, - LogOutputs: []string{DefaultLogOutput}, - Debug: false, - LogLevel: logutil.DefaultLogLevel, - LogPkgLevels: "", + loggerMu: new(sync.RWMutex), + logger: nil, + Logger: "zap", + LogOutputs: []string{DefaultLogOutput}, + LogLevel: logutil.DefaultLogLevel, } cfg.InitialCluster = cfg.InitialClusterFromName(cfg.Name) return cfg diff --git a/embed/config_logging.go b/embed/config_logging.go index e42103cb1..cdde4112d 100644 --- a/embed/config_logging.go +++ b/embed/config_logging.go @@ -16,16 +16,11 @@ package embed import ( "crypto/tls" - "errors" "fmt" - "io/ioutil" - "os" - "reflect" "sync" "go.etcd.io/etcd/pkg/logutil" - "github.com/coreos/pkg/capnslog" "go.uber.org/zap" "go.uber.org/zap/zapcore" "google.golang.org/grpc" @@ -46,91 +41,9 @@ var grpcLogOnce = new(sync.Once) // setupLogging initializes etcd logging. // Must be called after flag parsing or finishing configuring embed.Config. func (cfg *Config) setupLogging() error { - // handle "DeprecatedLogOutput" in v3.4 - // TODO: remove "DeprecatedLogOutput" in v3.5 - len1 := len(cfg.DeprecatedLogOutput) - len2 := len(cfg.LogOutputs) - if len1 != len2 { - switch { - case len1 > len2: // deprecate "log-output" flag is used - fmt.Fprintln(os.Stderr, "'--log-output' flag has been deprecated! Please use '--log-outputs'!") - cfg.LogOutputs = cfg.DeprecatedLogOutput - case len1 < len2: // "--log-outputs" flag has been set with multiple writers - cfg.DeprecatedLogOutput = []string{} - } - } else { - if len1 > 1 { - return errors.New("both '--log-output' and '--log-outputs' are set; only set '--log-outputs'") - } - if len1 < 1 { - return errors.New("either '--log-output' or '--log-outputs' flag must be set") - } - if reflect.DeepEqual(cfg.DeprecatedLogOutput, cfg.LogOutputs) && cfg.DeprecatedLogOutput[0] != DefaultLogOutput { - return fmt.Errorf("'--log-output=%q' and '--log-outputs=%q' are incompatible; only set --log-outputs", cfg.DeprecatedLogOutput, cfg.LogOutputs) - } - if !reflect.DeepEqual(cfg.DeprecatedLogOutput, []string{DefaultLogOutput}) { - fmt.Fprintf(os.Stderr, "[WARNING] Deprecated '--log-output' flag is set to %q\n", cfg.DeprecatedLogOutput) - fmt.Fprintln(os.Stderr, "Please use '--log-outputs' flag") - } - } - - // TODO: remove after deprecating log related flags in v3.5 - if cfg.Debug { - fmt.Fprintf(os.Stderr, "[WARNING] Deprecated '--debug' flag is set to %v (use '--log-level=debug' instead\n", cfg.Debug) - } - if cfg.Debug && cfg.LogLevel != "debug" { - fmt.Fprintf(os.Stderr, "[WARNING] Deprecated '--debug' flag is set to %v with inconsistent '--log-level=%s' flag\n", cfg.Debug, cfg.LogLevel) - } - if cfg.Logger == "capnslog" { - fmt.Fprintf(os.Stderr, "[WARNING] Deprecated '--logger=%s' flag is set; use '--logger=zap' flag instead\n", cfg.Logger) - } - if cfg.LogPkgLevels != "" { - fmt.Fprintf(os.Stderr, "[WARNING] Deprecated '--log-package-levels=%s' flag is set; use '--logger=zap' flag instead\n", cfg.LogPkgLevels) - } - switch cfg.Logger { - case "capnslog": // TODO: deprecate this in v3.5 - cfg.ClientTLSInfo.HandshakeFailure = logTLSHandshakeFailure - cfg.PeerTLSInfo.HandshakeFailure = logTLSHandshakeFailure - - if cfg.Debug { - capnslog.SetGlobalLogLevel(capnslog.DEBUG) - grpc.EnableTracing = true - // enable info, warning, error - grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr)) - } else { - capnslog.SetGlobalLogLevel(logutil.ConvertToCapnslogLogLevel(cfg.LogLevel)) - // only discard info - grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr)) - } - - // TODO: deprecate with "capnslog" - if cfg.LogPkgLevels != "" { - repoLog := capnslog.MustRepoLogger("go.etcd.io/etcd") - settings, err := repoLog.ParseLogLevelConfig(cfg.LogPkgLevels) - if err != nil { - plog.Warningf("couldn't parse log level string: %s, continuing with default levels", err.Error()) - return nil - } - repoLog.SetLogLevel(settings) - } - - if len(cfg.LogOutputs) != 1 { - return fmt.Errorf("--logger=capnslog supports only 1 value in '--log-outputs', got %q", cfg.LogOutputs) - } - // capnslog initially SetFormatter(NewDefaultFormatter(os.Stderr)) - // where NewDefaultFormatter returns NewJournaldFormatter when syscall.Getppid() == 1 - // specify 'stdout' or 'stderr' to skip journald logging even when running under systemd - output := cfg.LogOutputs[0] - switch output { - case StdErrLogOutput: - capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stderr, cfg.Debug)) - case StdOutLogOutput: - capnslog.SetFormatter(capnslog.NewPrettyFormatter(os.Stdout, cfg.Debug)) - case DefaultLogOutput: - default: - return fmt.Errorf("unknown log-output %q (only supports %q, %q, %q)", output, DefaultLogOutput, StdErrLogOutput, StdOutLogOutput) - } + case "capnslog": // removed in v3.5 + return fmt.Errorf("--logger=capnslog is removed in v3.5") case "zap": if len(cfg.LogOutputs) == 0 { @@ -175,10 +88,7 @@ func (cfg *Config) setupLogging() error { copied.ErrorOutputPaths = errOutputPaths copied = logutil.MergeOutputPaths(copied) copied.Level = zap.NewAtomicLevelAt(logutil.ConvertToZapLevel(cfg.LogLevel)) - if cfg.Debug || cfg.LogLevel == "debug" { - // enable tracing even when "--debug --log-level info" - // in order to keep backward compatibility with <= v3.3 - // TODO: remove "Debug" check in v3.5 + if cfg.LogLevel == "debug" { grpc.EnableTracing = true } if cfg.ZapLoggerBuilder == nil { @@ -221,10 +131,7 @@ func (cfg *Config) setupLogging() error { } lvl := zap.NewAtomicLevelAt(logutil.ConvertToZapLevel(cfg.LogLevel)) - if cfg.Debug || cfg.LogLevel == "debug" { - // enable tracing even when "--debug --log-level info" - // in order to keep backward compatibility with <= v3.3 - // TODO: remove "Debug" check in v3.5 + if cfg.LogLevel == "debug" { grpc.EnableTracing = true } diff --git a/embed/config_test.go b/embed/config_test.go index eacf181ba..263f9b275 100644 --- a/embed/config_test.go +++ b/embed/config_test.go @@ -159,7 +159,6 @@ func TestAutoCompactionModeInvalid(t *testing.T) { cfg := NewConfig() cfg.Logger = "zap" cfg.LogOutputs = []string{"/dev/null"} - cfg.Debug = false cfg.AutoCompactionMode = "period" err := cfg.Validate() if err == nil { diff --git a/embed/etcd.go b/embed/etcd.go index c9301bc25..6c43742bb 100644 --- a/embed/etcd.go +++ b/embed/etcd.go @@ -201,7 +201,6 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) { LoggerConfig: cfg.loggerConfig, LoggerCore: cfg.loggerCore, LoggerWriteSyncer: cfg.loggerWriteSyncer, - Debug: cfg.Debug, ForceNewCluster: cfg.ForceNewCluster, EnableGRPCGateway: cfg.EnableGRPCGateway, EnableLeaseCheckpoint: cfg.ExperimentalEnableLeaseCheckpoint, @@ -691,10 +690,10 @@ func configureClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err erro sctx.userHandlers[k] = cfg.UserHandlers[k] } sctx.serviceRegister = cfg.ServiceRegister - if cfg.EnablePprof || cfg.Debug { + if cfg.EnablePprof || cfg.LogLevel == "debug" { sctx.registerPprof() } - if cfg.Debug { + if cfg.LogLevel == "debug" { sctx.registerTrace() } sctxs[addr] = sctx diff --git a/etcdmain/config.go b/etcdmain/config.go index 28a10bb07..c3686abde 100644 --- a/etcdmain/config.go +++ b/etcdmain/config.go @@ -221,12 +221,9 @@ func newConfig() *config { fs.Var(flags.NewUniqueStringsValue("*"), "host-whitelist", "Comma-separated acceptable hostnames from HTTP client requests, if server is not secure (empty means allow all).") // logging - fs.StringVar(&cfg.ec.Logger, "logger", "capnslog", "Specify 'zap' for structured logging or 'capnslog'. WARN: 'capnslog' is being deprecated in v3.5.") - fs.Var(flags.NewUniqueStringsValue(embed.DefaultLogOutput), "log-output", "[TO BE DEPRECATED IN v3.5] use '--log-outputs'.") + fs.StringVar(&cfg.ec.Logger, "logger", "zap", "Currently only supports 'zap' for structured logging.") fs.Var(flags.NewUniqueStringsValue(embed.DefaultLogOutput), "log-outputs", "Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd, or list of comma separated output targets.") - fs.BoolVar(&cfg.ec.Debug, "debug", false, "[TO BE DEPRECATED IN v3.5] Enable debug-level logging for etcd. Use '--log-level=debug' instead.") fs.StringVar(&cfg.ec.LogLevel, "log-level", logutil.DefaultLogLevel, "Configures log level. Only supports debug, info, warn, error, panic, or fatal. Default 'info'.") - fs.StringVar(&cfg.ec.LogPkgLevels, "log-package-levels", "", "[TO BE DEPRECATED IN v3.5] Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG').") // version fs.BoolVar(&cfg.printVersion, "version", false, "Print the version and exit.") @@ -336,8 +333,6 @@ func (cfg *config) configFromCmdLine() error { cfg.ec.CipherSuites = flags.StringsFromFlag(cfg.cf.flagSet, "cipher-suites") - // TODO: remove this in v3.5 - cfg.ec.DeprecatedLogOutput = flags.UniqueStringsFromFlag(cfg.cf.flagSet, "log-output") cfg.ec.LogOutputs = flags.UniqueStringsFromFlag(cfg.cf.flagSet, "log-outputs") cfg.ec.ClusterState = cfg.cf.clusterState.String() diff --git a/etcdmain/help.go b/etcdmain/help.go index 244b798cf..73874cb36 100644 --- a/etcdmain/help.go +++ b/etcdmain/help.go @@ -174,8 +174,8 @@ Profiling and Monitoring: List of URLs to listen on for the metrics and health endpoints. Logging: - --logger 'capnslog' - Specify 'zap' for structured logging or 'capnslog'. [WARN] 'capnslog' will be deprecated in v3.5. + --logger 'zap' + Currently only supports 'zap' for structured logging. --log-outputs 'default' Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd, or list of comma separated output targets. --log-level 'info' @@ -214,12 +214,7 @@ Unsafe feature: Force to create a new one-member cluster. CAUTIOUS with unsafe flag! It may break the guarantees given by the consensus protocol! - -TO BE DEPRECATED: - - --debug 'false' - Enable debug-level logging for etcd. [WARN] Will be deprecated in v3.5. Use '--log-level=debug' instead. - --log-package-levels '' - Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG'). ` ) + +// Add back "TO BE DEPRECATED" section if needed diff --git a/etcdserver/config.go b/etcdserver/config.go index 88cd721c3..426059b45 100644 --- a/etcdserver/config.go +++ b/etcdserver/config.go @@ -147,8 +147,6 @@ type ServerConfig struct { LoggerCore zapcore.Core LoggerWriteSyncer zapcore.WriteSyncer - Debug bool - ForceNewCluster bool // EnableLeaseCheckpoint enables primary lessor to persist lease remainingTTL to prevent indefinite auto-renewal of long lived leases. diff --git a/integration/embed_test.go b/integration/embed_test.go index c95d78d35..2bc5f44d7 100644 --- a/integration/embed_test.go +++ b/integration/embed_test.go @@ -58,7 +58,6 @@ func TestEmbedEtcd(t *testing.T) { tests[i].cfg = *embed.NewConfig() tests[i].cfg.Logger = "zap" tests[i].cfg.LogOutputs = []string{"/dev/null"} - tests[i].cfg.Debug = false } tests[0].cfg.Durl = "abc" @@ -184,7 +183,6 @@ func newEmbedURLs(secure bool, n int) (urls []url.URL) { func setupEmbedCfg(cfg *embed.Config, curls []url.URL, purls []url.URL) { cfg.Logger = "zap" cfg.LogOutputs = []string{"/dev/null"} - cfg.Debug = false cfg.ClusterState = "new" cfg.LCUrls, cfg.ACUrls = curls, curls diff --git a/tools/etcd-dump-metrics/etcd.go b/tools/etcd-dump-metrics/etcd.go index 2939b60c2..638e34236 100644 --- a/tools/etcd-dump-metrics/etcd.go +++ b/tools/etcd-dump-metrics/etcd.go @@ -42,7 +42,6 @@ func setupEmbedCfg(cfg *embed.Config, curls, purls, ics []url.URL) { cfg.Logger = "zap" cfg.LogOutputs = []string{"/dev/null"} // []string{"stderr"} to enable server logging - cfg.Debug = false var err error cfg.Dir, err = ioutil.TempDir(os.TempDir(), fmt.Sprintf("%016X", time.Now().UnixNano()))