-
Notifications
You must be signed in to change notification settings - Fork 0
/
grpc_log.go
73 lines (58 loc) · 1.3 KB
/
grpc_log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package extend
import (
"github.com/geekymedic/neon/logger"
"google.golang.org/grpc/grpclog"
)
var defLog *GrpcLog
type GrpcLog struct {
logger.Logger
GrpcExtendLog
}
type GrpcExtendLog interface {
Infoln(args ...interface{})
Debugln(args ...interface{})
Errorln(args ...interface{})
Fatalln(args ...interface{})
Warning(args ...interface{})
Warnln(args ...interface{})
V(l int) bool
}
func init() {
defLog = &GrpcLog{Logger: logger.DefLogger()}
}
func (log *GrpcLog) Infoln(args ...interface{}) {
log.Info(args...)
}
func (log *GrpcLog) Debugln(args ...interface{}) {
log.Debug(args...)
}
func (log *GrpcLog) Warning(args ...interface{}) {
log.Warning(args...)
}
func (log *GrpcLog) Warningln(args ...interface{}) {
log.Warn(args...)
}
func (log *GrpcLog) Warningf(format string, args ...interface{}) {
log.Warnf(format, args...)
}
func (log *GrpcLog) Warnln(args ...interface{}) {
log.Warn(args...)
}
func (log *GrpcLog) Errorln(args ...interface{}) {
log.Errorln(args...)
}
func (log *GrpcLog) Fatalln(args ...interface{}) {
log.Fatalln(args...)
}
func (log *GrpcLog) V(l int) bool {
return log.SetLevel(logger.Level(l))
}
func ReplaceGrpcLogger() {
grpclog.SetLoggerV2(defLog)
}
func SetGrpcLog(log logger.Logger) {
defLog = &GrpcLog{Logger: log}
}
func DefGrpLog() *GrpcLog {
return defLog
}