fix golint issues in core/logx (#496)

This commit is contained in:
Kevin Wan
2021-02-20 22:45:58 +08:00
committed by GitHub
parent dac00d10c1
commit 226513ed60
9 changed files with 74 additions and 28 deletions

View File

@@ -1,21 +1,25 @@
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 ...interface{}) {
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 ...interface{}) {
logger.logOrDiscard(func() {
Errorf(format, v...)