Skip to content

Commit

Permalink
Merge pull request #290 from pohly/v-filter
Browse files Browse the repository at this point in the history
log filter: ignored by V, used during log call
  • Loading branch information
k8s-ci-robot committed Feb 9, 2022
2 parents d78dad3 + 892e4f4 commit ac3fc4d
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions klog.go
Expand Up @@ -1392,15 +1392,14 @@ func (l *loggingT) setV(pc uintptr) Level {
type Verbose struct {
enabled bool
logr *logr.Logger
filter LogFilter
}

func newVerbose(level Level, b bool) Verbose {
if logging.logr == nil {
return Verbose{b, nil, logging.filter}
return Verbose{b, nil}
}
v := logging.logr.V(int(level))
return Verbose{b, &v, logging.filter}
return Verbose{b, &v}
}

// V reports whether verbosity at the call site is at least the requested level.
Expand Down Expand Up @@ -1463,55 +1462,55 @@ func (v Verbose) Enabled() bool {
// See the documentation of V for usage.
func (v Verbose) Info(args ...interface{}) {
if v.enabled {
logging.print(infoLog, v.logr, v.filter, args...)
logging.print(infoLog, v.logr, logging.filter, args...)
}
}

// InfoDepth is equivalent to the global InfoDepth function, guarded by the value of v.
// See the documentation of V for usage.
func (v Verbose) InfoDepth(depth int, args ...interface{}) {
if v.enabled {
logging.printDepth(infoLog, v.logr, v.filter, depth, args...)
logging.printDepth(infoLog, v.logr, logging.filter, depth, args...)
}
}

// Infoln is equivalent to the global Infoln function, guarded by the value of v.
// See the documentation of V for usage.
func (v Verbose) Infoln(args ...interface{}) {
if v.enabled {
logging.println(infoLog, v.logr, v.filter, args...)
logging.println(infoLog, v.logr, logging.filter, args...)
}
}

// InfolnDepth is equivalent to the global InfolnDepth function, guarded by the value of v.
// See the documentation of V for usage.
func (v Verbose) InfolnDepth(depth int, args ...interface{}) {
if v.enabled {
logging.printlnDepth(infoLog, v.logr, v.filter, depth, args...)
logging.printlnDepth(infoLog, v.logr, logging.filter, depth, args...)
}
}

// Infof is equivalent to the global Infof function, guarded by the value of v.
// See the documentation of V for usage.
func (v Verbose) Infof(format string, args ...interface{}) {
if v.enabled {
logging.printf(infoLog, v.logr, v.filter, format, args...)
logging.printf(infoLog, v.logr, logging.filter, format, args...)
}
}

// InfofDepth is equivalent to the global InfofDepth function, guarded by the value of v.
// See the documentation of V for usage.
func (v Verbose) InfofDepth(depth int, format string, args ...interface{}) {
if v.enabled {
logging.printfDepth(infoLog, v.logr, v.filter, depth, format, args...)
logging.printfDepth(infoLog, v.logr, logging.filter, depth, format, args...)
}
}

// InfoS is equivalent to the global InfoS function, guarded by the value of v.
// See the documentation of V for usage.
func (v Verbose) InfoS(msg string, keysAndValues ...interface{}) {
if v.enabled {
logging.infoS(v.logr, v.filter, 0, msg, keysAndValues...)
logging.infoS(v.logr, logging.filter, 0, msg, keysAndValues...)
}
}

Expand All @@ -1525,22 +1524,22 @@ func InfoSDepth(depth int, msg string, keysAndValues ...interface{}) {
// See the documentation of V for usage.
func (v Verbose) InfoSDepth(depth int, msg string, keysAndValues ...interface{}) {
if v.enabled {
logging.infoS(v.logr, v.filter, depth, msg, keysAndValues...)
logging.infoS(v.logr, logging.filter, depth, msg, keysAndValues...)
}
}

// Deprecated: Use ErrorS instead.
func (v Verbose) Error(err error, msg string, args ...interface{}) {
if v.enabled {
logging.errorS(err, v.logr, v.filter, 0, msg, args...)
logging.errorS(err, v.logr, logging.filter, 0, msg, args...)
}
}

// ErrorS is equivalent to the global Error function, guarded by the value of v.
// See the documentation of V for usage.
func (v Verbose) ErrorS(err error, msg string, keysAndValues ...interface{}) {
if v.enabled {
logging.errorS(err, v.logr, v.filter, 0, msg, keysAndValues...)
logging.errorS(err, v.logr, logging.filter, 0, msg, keysAndValues...)
}
}

Expand Down

0 comments on commit ac3fc4d

Please sign in to comment.