mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: bump k8s.io/klog/v2 from 2.60.1 to 2.70.1
Bumps [k8s.io/klog/v2](https://github.com/kubernetes/klog) from 2.60.1 to 2.70.1. - [Release notes](https://github.com/kubernetes/klog/releases) - [Changelog](https://github.com/kubernetes/klog/blob/main/RELEASE.md) - [Commits](https://github.com/kubernetes/klog/compare/v2.60.1...v2.70.1) --- updated-dependencies: - dependency-name: k8s.io/klog/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
mergify[bot]
parent
f171143135
commit
f8c8ff6c70
38
vendor/k8s.io/klog/v2/contextual.go
generated
vendored
38
vendor/k8s.io/klog/v2/contextual.go
generated
vendored
@ -34,18 +34,6 @@ import (
|
||||
// mutex locking.
|
||||
|
||||
var (
|
||||
// contextualLoggingEnabled controls whether contextual logging is
|
||||
// active. Disabling it may have some small performance benefit.
|
||||
contextualLoggingEnabled = true
|
||||
|
||||
// globalLogger is the global Logger chosen by users of klog, nil if
|
||||
// none is available.
|
||||
globalLogger *Logger
|
||||
|
||||
// globalLoggerOptions contains the options that were supplied for
|
||||
// globalLogger.
|
||||
globalLoggerOptions loggerOptions
|
||||
|
||||
// klogLogger is used as fallback for logging through the normal klog code
|
||||
// when no Logger is set.
|
||||
klogLogger logr.Logger = logr.New(&klogger{})
|
||||
@ -81,10 +69,10 @@ func SetLogger(logger logr.Logger) {
|
||||
// routing log entries through klogr into klog and then into the actual Logger
|
||||
// backend.
|
||||
func SetLoggerWithOptions(logger logr.Logger, opts ...LoggerOption) {
|
||||
globalLogger = &logger
|
||||
globalLoggerOptions = loggerOptions{}
|
||||
logging.logger = &logger
|
||||
logging.loggerOptions = loggerOptions{}
|
||||
for _, opt := range opts {
|
||||
opt(&globalLoggerOptions)
|
||||
opt(&logging.loggerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,8 +107,8 @@ type loggerOptions struct {
|
||||
// Modifying the logger is not thread-safe and should be done while no other
|
||||
// goroutines invoke log calls, usually during program initialization.
|
||||
func ClearLogger() {
|
||||
globalLogger = nil
|
||||
globalLoggerOptions = loggerOptions{}
|
||||
logging.logger = nil
|
||||
logging.loggerOptions = loggerOptions{}
|
||||
}
|
||||
|
||||
// EnableContextualLogging controls whether contextual logging is enabled.
|
||||
@ -132,14 +120,14 @@ func ClearLogger() {
|
||||
//
|
||||
// This must be called during initialization before goroutines are started.
|
||||
func EnableContextualLogging(enabled bool) {
|
||||
contextualLoggingEnabled = enabled
|
||||
logging.contextualLoggingEnabled = enabled
|
||||
}
|
||||
|
||||
// FromContext retrieves a logger set by the caller or, if not set,
|
||||
// falls back to the program's global logger (a Logger instance or klog
|
||||
// itself).
|
||||
func FromContext(ctx context.Context) Logger {
|
||||
if contextualLoggingEnabled {
|
||||
if logging.contextualLoggingEnabled {
|
||||
if logger, err := logr.FromContext(ctx); err == nil {
|
||||
return logger
|
||||
}
|
||||
@ -160,10 +148,10 @@ func TODO() Logger {
|
||||
// better receive a logger via its parameters. TODO can be used as a temporary
|
||||
// solution for such code.
|
||||
func Background() Logger {
|
||||
if globalLoggerOptions.contextualLogger {
|
||||
// Is non-nil because globalLoggerOptions.contextualLogger is
|
||||
if logging.loggerOptions.contextualLogger {
|
||||
// Is non-nil because logging.loggerOptions.contextualLogger is
|
||||
// only true if a logger was set.
|
||||
return *globalLogger
|
||||
return *logging.logger
|
||||
}
|
||||
|
||||
return klogLogger
|
||||
@ -172,7 +160,7 @@ func Background() Logger {
|
||||
// LoggerWithValues returns logger.WithValues(...kv) when
|
||||
// contextual logging is enabled, otherwise the logger.
|
||||
func LoggerWithValues(logger Logger, kv ...interface{}) Logger {
|
||||
if contextualLoggingEnabled {
|
||||
if logging.contextualLoggingEnabled {
|
||||
return logger.WithValues(kv...)
|
||||
}
|
||||
return logger
|
||||
@ -181,7 +169,7 @@ func LoggerWithValues(logger Logger, kv ...interface{}) Logger {
|
||||
// LoggerWithName returns logger.WithName(name) when contextual logging is
|
||||
// enabled, otherwise the logger.
|
||||
func LoggerWithName(logger Logger, name string) Logger {
|
||||
if contextualLoggingEnabled {
|
||||
if logging.contextualLoggingEnabled {
|
||||
return logger.WithName(name)
|
||||
}
|
||||
return logger
|
||||
@ -190,7 +178,7 @@ func LoggerWithName(logger Logger, name string) Logger {
|
||||
// NewContext returns logr.NewContext(ctx, logger) when
|
||||
// contextual logging is enabled, otherwise ctx.
|
||||
func NewContext(ctx context.Context, logger Logger) context.Context {
|
||||
if contextualLoggingEnabled {
|
||||
if logging.contextualLoggingEnabled {
|
||||
return logr.NewContext(ctx, logger)
|
||||
}
|
||||
return ctx
|
||||
|
Reference in New Issue
Block a user