mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-10 00:29:01 +02:00
801f89b6db
* rename Print to Log
32 lines
791 B
Go
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
|
|
}
|