From 2db83caf29630b5a65604d1b50a1df946bf92abd Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Tue, 3 Mar 2020 13:36:20 +0300 Subject: [PATCH] used logger custom interface instead of grpclog.LoggerV2 --- logger.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/logger.go b/logger.go index 21588e1..3bb969e 100644 --- a/logger.go +++ b/logger.go @@ -10,10 +10,17 @@ import ( "go.uber.org/zap/zapcore" ) -type zapLogger struct { - zapcore.Core - log *zap.SugaredLogger -} +type ( + zapLogger struct { + zapcore.Core + log *zap.SugaredLogger + } + + logger interface { + grpclog.LoggerV2 + Println(v ...interface{}) + } +) const ( formatJSON = "json" @@ -23,7 +30,7 @@ const ( defaultSamplingThereafter = 100 ) -func gRPCLogger(l *zap.Logger) grpclog.LoggerV2 { +func gRPCLogger(l *zap.Logger) logger { log := l.WithOptions( // skip gRPCLog + zapLogger in caller zap.AddCallerSkip(2))