Add skip level for rated log (#25765)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/25774/head
congqixia 2023-07-19 20:43:02 +08:00 committed by GitHub
parent 0695ce030b
commit fc6f0f97a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -60,7 +60,7 @@ func (l *MLogger) r() utils.RateLimiter {
// RatedDebug calls log.Debug with RateLimiter.
func (l *MLogger) RatedDebug(cost float64, msg string, fields ...zap.Field) bool {
if l.r().CheckCredit(cost) {
l.Debug(msg, fields...)
l.WithOptions(zap.AddCallerSkip(1)).Debug(msg, fields...)
return true
}
return false
@ -69,7 +69,7 @@ func (l *MLogger) RatedDebug(cost float64, msg string, fields ...zap.Field) bool
// RatedInfo calls log.Info with RateLimiter.
func (l *MLogger) RatedInfo(cost float64, msg string, fields ...zap.Field) bool {
if l.r().CheckCredit(cost) {
l.Info(msg, fields...)
l.WithOptions(zap.AddCallerSkip(1)).Info(msg, fields...)
return true
}
return false
@ -78,7 +78,7 @@ func (l *MLogger) RatedInfo(cost float64, msg string, fields ...zap.Field) bool
// RatedWarn calls log.Warn with RateLimiter.
func (l *MLogger) RatedWarn(cost float64, msg string, fields ...zap.Field) bool {
if l.r().CheckCredit(cost) {
l.Warn(msg, fields...)
l.WithOptions(zap.AddCallerSkip(1)).Warn(msg, fields...)
return true
}
return false