mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: bump the k8s-dependencies group with 1 update
Bumps the k8s-dependencies group with 1 update: [k8s.io/klog/v2](https://github.com/kubernetes/klog). - [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.100.1...v2.110.1) --- updated-dependencies: - dependency-name: k8s.io/klog/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: k8s-dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
mergify[bot]
parent
dc655f03a8
commit
1c1d852080
46
vendor/k8s.io/klog/v2/klogr.go
generated
vendored
46
vendor/k8s.io/klog/v2/klogr.go
generated
vendored
@ -22,6 +22,11 @@ import (
|
||||
"k8s.io/klog/v2/internal/serialize"
|
||||
)
|
||||
|
||||
const (
|
||||
// nameKey is used to log the `WithName` values as an additional attribute.
|
||||
nameKey = "logger"
|
||||
)
|
||||
|
||||
// NewKlogr returns a logger that is functionally identical to
|
||||
// klogr.NewWithOptions(klogr.FormatKlog), i.e. it passes through to klog. The
|
||||
// difference is that it uses a simpler implementation.
|
||||
@ -32,10 +37,15 @@ func NewKlogr() Logger {
|
||||
// klogger is a subset of klogr/klogr.go. It had to be copied to break an
|
||||
// import cycle (klogr wants to use klog, and klog wants to use klogr).
|
||||
type klogger struct {
|
||||
level int
|
||||
callDepth int
|
||||
prefix string
|
||||
values []interface{}
|
||||
|
||||
// hasPrefix is true if the first entry in values is the special
|
||||
// nameKey key/value. Such an entry gets added and later updated in
|
||||
// WithName.
|
||||
hasPrefix bool
|
||||
|
||||
values []interface{}
|
||||
groups string
|
||||
}
|
||||
|
||||
func (l *klogger) Init(info logr.RuntimeInfo) {
|
||||
@ -44,34 +54,40 @@ func (l *klogger) Init(info logr.RuntimeInfo) {
|
||||
|
||||
func (l *klogger) Info(level int, msg string, kvList ...interface{}) {
|
||||
merged := serialize.MergeKVs(l.values, kvList)
|
||||
if l.prefix != "" {
|
||||
msg = l.prefix + ": " + msg
|
||||
}
|
||||
// Skip this function.
|
||||
VDepth(l.callDepth+1, Level(level)).InfoSDepth(l.callDepth+1, msg, merged...)
|
||||
}
|
||||
|
||||
func (l *klogger) Enabled(level int) bool {
|
||||
// Skip this function and logr.Logger.Info where Enabled is called.
|
||||
return VDepth(l.callDepth+2, Level(level)).Enabled()
|
||||
return VDepth(l.callDepth+1, Level(level)).Enabled()
|
||||
}
|
||||
|
||||
func (l *klogger) Error(err error, msg string, kvList ...interface{}) {
|
||||
merged := serialize.MergeKVs(l.values, kvList)
|
||||
if l.prefix != "" {
|
||||
msg = l.prefix + ": " + msg
|
||||
}
|
||||
ErrorSDepth(l.callDepth+1, err, msg, merged...)
|
||||
}
|
||||
|
||||
// WithName returns a new logr.Logger with the specified name appended. klogr
|
||||
// uses '/' characters to separate name elements. Callers should not pass '/'
|
||||
// uses '.' characters to separate name elements. Callers should not pass '.'
|
||||
// in the provided name string, but this library does not actually enforce that.
|
||||
func (l klogger) WithName(name string) logr.LogSink {
|
||||
if len(l.prefix) > 0 {
|
||||
l.prefix = l.prefix + "/"
|
||||
if l.hasPrefix {
|
||||
// Copy slice and modify value. No length checks and type
|
||||
// assertions are needed because hasPrefix is only true if the
|
||||
// first two elements exist and are key/value strings.
|
||||
v := make([]interface{}, 0, len(l.values))
|
||||
v = append(v, l.values...)
|
||||
prefix, _ := v[1].(string)
|
||||
v[1] = prefix + "." + name
|
||||
l.values = v
|
||||
} else {
|
||||
// Preprend new key/value pair.
|
||||
v := make([]interface{}, 0, 2+len(l.values))
|
||||
v = append(v, nameKey, name)
|
||||
v = append(v, l.values...)
|
||||
l.values = v
|
||||
l.hasPrefix = true
|
||||
}
|
||||
l.prefix += name
|
||||
return &l
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user