used logger custom interface instead of grpclog.LoggerV2
This commit is contained in:
parent
50e74ee3a1
commit
2db83caf29
1 changed files with 12 additions and 5 deletions
11
logger.go
11
logger.go
|
@ -10,11 +10,18 @@ import (
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type zapLogger struct {
|
type (
|
||||||
|
zapLogger struct {
|
||||||
zapcore.Core
|
zapcore.Core
|
||||||
log *zap.SugaredLogger
|
log *zap.SugaredLogger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger interface {
|
||||||
|
grpclog.LoggerV2
|
||||||
|
Println(v ...interface{})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
formatJSON = "json"
|
formatJSON = "json"
|
||||||
formatConsole = "console"
|
formatConsole = "console"
|
||||||
|
@ -23,7 +30,7 @@ const (
|
||||||
defaultSamplingThereafter = 100
|
defaultSamplingThereafter = 100
|
||||||
)
|
)
|
||||||
|
|
||||||
func gRPCLogger(l *zap.Logger) grpclog.LoggerV2 {
|
func gRPCLogger(l *zap.Logger) logger {
|
||||||
log := l.WithOptions(
|
log := l.WithOptions(
|
||||||
// skip gRPCLog + zapLogger in caller
|
// skip gRPCLog + zapLogger in caller
|
||||||
zap.AddCallerSkip(2))
|
zap.AddCallerSkip(2))
|
||||||
|
|
Loading…
Reference in a new issue