mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
ae87114282
* chore: change interface{} to any * chore: update goctl version to 1.5.0 * chore: update goctl deps
28 lines
709 B
Go
28 lines
709 B
Go
package logx
|
|
|
|
// A LessLogger is a logger that control to log once during the given duration.
|
|
type LessLogger struct {
|
|
*limitedExecutor
|
|
}
|
|
|
|
// NewLessLogger returns a LessLogger.
|
|
func NewLessLogger(milliseconds int) *LessLogger {
|
|
return &LessLogger{
|
|
limitedExecutor: newLimitedExecutor(milliseconds),
|
|
}
|
|
}
|
|
|
|
// Error logs v into error log or discard it if more than once in the given duration.
|
|
func (logger *LessLogger) Error(v ...any) {
|
|
logger.logOrDiscard(func() {
|
|
Error(v...)
|
|
})
|
|
}
|
|
|
|
// Errorf logs v with format into error log or discard it if more than once in the given duration.
|
|
func (logger *LessLogger) Errorf(format string, v ...any) {
|
|
logger.logOrDiscard(func() {
|
|
Errorf(format, v...)
|
|
})
|
|
}
|