1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-10 00:29:01 +02:00
kratos/log/verbose.go
Tony Chen 801f89b6db
log: rename Print to Log (#886)
* rename Print to Log
2021-05-01 01:15:30 +08:00

32 lines
791 B
Go

package log
// Verbose is a verbose type that implements Logger Print.
type Verbose struct {
log Logger
level Level
enabled bool
}
// NewVerbose new a verbose with level.
func NewVerbose(log Logger, level Level) Verbose {
return Verbose{log: log, level: level}
}
// Enabled will return true if this log level is enabled, guarded by the value of v.
func (v Verbose) Enabled(level Level) bool {
return v.level <= level
}
// V reports whether verbosity at the call site is at least the requested level.
func (v Verbose) V(level Level) Verbose {
return Verbose{log: v.log, enabled: v.Enabled(level)}
}
// Log is equivalent to the Print function, guarded by the value of v.
func (v Verbose) Log(a ...interface{}) error {
if v.enabled {
return v.log.Log(a...)
}
return nil
}