Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log filter: ignored by V, used during log call #290

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions klog.go
Original file line number Diff line number Diff line change
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