diff --git a/staging/src/k8s.io/component-base/logs/logs.go b/staging/src/k8s.io/component-base/logs/logs.go index 0f494deedd0..8276a9cadc0 100644 --- a/staging/src/k8s.io/component-base/logs/logs.go +++ b/staging/src/k8s.io/component-base/logs/logs.go @@ -41,7 +41,6 @@ const deprecated = "will be removed in a future release, see https://github.com/ var ( packageFlags = flag.NewFlagSet("logging", flag.ContinueOnError) - logrFlush func() // Periodic flushing gets configured either via the global flag // in this file or via LoggingConfiguration. @@ -185,9 +184,6 @@ func InitLogs() { // are printed before exiting the program. func FlushLogs() { klog.Flush() - if logrFlush != nil { - logrFlush() - } } // NewLogger creates a new log.Logger which sends logs to klog.Info. diff --git a/staging/src/k8s.io/component-base/logs/options.go b/staging/src/k8s.io/component-base/logs/options.go index c9f41bab134..c629399ed1a 100644 --- a/staging/src/k8s.io/component-base/logs/options.go +++ b/staging/src/k8s.io/component-base/logs/options.go @@ -82,8 +82,7 @@ func (o *Options) apply() { klog.ClearLogger() } else { log, flush := factory.Create(o.Config.Options) - klog.SetLogger(log) - logrFlush = flush + klog.SetLoggerWithOptions(log, klog.FlushLogger(flush)) } if err := loggingFlags.Lookup("v").Value.Set(o.Config.Verbosity.String()); err != nil { panic(fmt.Errorf("internal error while setting klog verbosity: %v", err))