forked from ohsu-comp-bio/funnel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grpc.go
70 lines (65 loc) · 1.78 KB
/
grpc.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
package logger
import (
"fmt"
"google.golang.org/grpc/grpclog"
"os"
)
func init() {
ConfigureGRPC(2, NewLogger("grpc", DefaultConfig()))
}
// ConfigureGRPC configures the GRPC logger verboisty level.
// All logs in transport package only go to verbose level 2.
// All logs in other packages in grpc are logged in spite of the verbosity level.
func ConfigureGRPC(verbosity int, log *Logger) {
grpclog.SetLoggerV2(&grpclogger{
verbosity: verbosity,
log: log,
})
}
// Configure the GRPC logger to use the global logrus configuration
type grpclogger struct {
verbosity int
log *Logger
}
func (g *grpclogger) Info(args ...interface{}) {
g.log.Info(fmt.Sprint(args))
}
func (g *grpclogger) Infoln(args ...interface{}) {
g.log.Info(fmt.Sprint(args))
}
func (g *grpclogger) Infof(format string, args ...interface{}) {
g.log.Info(fmt.Sprintf(format, args))
}
func (g *grpclogger) Warning(args ...interface{}) {
g.log.Error(fmt.Sprint(args))
}
func (g *grpclogger) Warningln(args ...interface{}) {
g.log.Error(fmt.Sprint(args))
}
func (g *grpclogger) Warningf(format string, args ...interface{}) {
g.log.Error(fmt.Sprintf(format, args))
}
func (g *grpclogger) Error(args ...interface{}) {
g.log.Error(fmt.Sprint(args))
}
func (g *grpclogger) Errorln(args ...interface{}) {
g.log.Error(fmt.Sprint(args))
}
func (g *grpclogger) Errorf(format string, args ...interface{}) {
g.log.Error(fmt.Sprintf(format, args))
}
func (g *grpclogger) Fatal(args ...interface{}) {
g.log.Error(fmt.Sprint(args))
os.Exit(1)
}
func (g *grpclogger) Fatalln(args ...interface{}) {
g.log.Error(fmt.Sprint(args))
os.Exit(1)
}
func (g *grpclogger) Fatalf(format string, args ...interface{}) {
g.log.Error(fmt.Sprintf(format, args))
os.Exit(1)
}
func (g *grpclogger) V(l int) bool {
return g.verbosity >= l
}