forked from zeromicro/go-zero
/
rpclogger.go
81 lines (64 loc) · 1.81 KB
/
rpclogger.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
74
75
76
77
78
79
80
81
package internal
import (
"github.com/Peakchen/go-zero/core/logx"
"google.golang.org/grpc/grpclog"
)
// because grpclog.errorLog is not exported, we need to define our own.
const errorLevel = 2
// A Logger is a rpc logger.
type Logger struct{}
func init() {
grpclog.SetLoggerV2(new(Logger))
}
// Error logs the given args into error log.
func (l *Logger) Error(args ...any) {
logx.Error(args...)
}
// Errorf logs the given args with format into error log.
func (l *Logger) Errorf(format string, args ...any) {
logx.Errorf(format, args...)
}
// Errorln logs the given args into error log with newline.
func (l *Logger) Errorln(args ...any) {
logx.Error(args...)
}
// Fatal logs the given args into error log.
func (l *Logger) Fatal(args ...any) {
logx.Error(args...)
}
// Fatalf logs the given args with format into error log.
func (l *Logger) Fatalf(format string, args ...any) {
logx.Errorf(format, args...)
}
// Fatalln logs args into error log with newline.
func (l *Logger) Fatalln(args ...any) {
logx.Error(args...)
}
// Info ignores the grpc info logs.
func (l *Logger) Info(args ...any) {
// ignore builtin grpc info
}
// Infoln ignores the grpc info logs.
func (l *Logger) Infoln(args ...any) {
// ignore builtin grpc info
}
// Infof ignores the grpc info logs.
func (l *Logger) Infof(format string, args ...any) {
// ignore builtin grpc info
}
// V checks if meet required log level.
func (l *Logger) V(v int) bool {
return v >= errorLevel
}
// Warning ignores the grpc warning logs.
func (l *Logger) Warning(args ...any) {
// ignore builtin grpc warning
}
// Warningf ignores the grpc warning logs.
func (l *Logger) Warningf(format string, args ...any) {
// ignore builtin grpc warning
}
// Warningln ignores the grpc warning logs.
func (l *Logger) Warningln(args ...any) {
// ignore builtin grpc warning
}