diff options
| author | Taras Madan <tarasmadan@google.com> | 2022-10-24 18:31:00 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2022-10-24 20:39:44 +0200 |
| commit | ac78f484f7dacebef88ef5f301183eac6322e7e7 (patch) | |
| tree | 248ccb972cebed6a7e54f45914fbe50d09587b9e | |
| parent | 914c54c355c0a93e7c8696bb4f5750da2c5c17b6 (diff) | |
pkg/log: add V() support to check verbosity
| -rw-r--r-- | pkg/log/log.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pkg/log/log.go b/pkg/log/log.go index a3ff96696..92063f6de 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -59,9 +59,14 @@ func CachedLogOutput() string { return buf.String() } +// V reports whether verbosity at the call site is at least the requested level. +// See https://pkg.go.dev/github.com/golang/glog#V for details. +func V(level int) bool { + return level <= *flagV +} + func Logf(v int, msg string, args ...interface{}) { mu.Lock() - doLog := v <= *flagV if cacheEntries != nil && v <= 1 { cacheMem -= len(cacheEntries[cachePos]) if cacheMem < 0 { @@ -88,7 +93,7 @@ func Logf(v int, msg string, args ...interface{}) { } mu.Unlock() - if doLog { + if V(v) { golog.Printf(msg, args...) } } |
