Add With method for MLogger (#21530) (#21535)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2023-01-05 14:31:36 +08:00 committed by GitHub
parent cf5c933df2
commit 6d030a07dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,14 @@ type MLogger struct {
*zap.Logger
}
// With encapsulates zap.Logger With method to return MLogger instance.
func (l *MLogger) With(fields ...zap.Field) *MLogger {
nl := &MLogger{
Logger: l.Logger.With(fields...),
}
return nl
}
func (l *MLogger) RatedDebug(cost float64, msg string, fields ...zap.Field) bool {
if R().CheckCredit(cost) {
l.Debug(msg, fields...)