forked from phuslu/log
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrpc_test.go
54 lines (44 loc) · 1.89 KB
/
grpc_test.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
package log
import (
"testing"
)
func TestGrpcLogger(t *testing.T) {
DefaultLogger.Caller = 1
DefaultLogger.Writer = &ConsoleWriter{ColorOutput: true, EndWithMessage: true}
var grpclog grpcLoggerV2 = DefaultLogger.Grpc(NewContext(nil).Str("tag", "hi sugar").Value())
notTest = false
grpclog.Info("hello", "grpclog Info message")
grpclog.Infoln("hello", "grpclog Infoln message")
grpclog.Infof("hello %s", "grpclog Infof message")
grpclog.Warning("hello", "grpclog Warning message")
grpclog.Warningln("hello", "grpclog Warningln message")
grpclog.Warningf("hello %s", "grpclog Warningf message")
grpclog.Error("hello", "grpclog Error message")
grpclog.Errorln("hello", "grpclog Errorln message")
grpclog.Errorf("hello %s", "grpclog Errorf message")
grpclog.Fatal("hello", "grpclog Fatal message")
grpclog.Fatalln("hello", "grpclog Fatalln message")
grpclog.Fatalf("hello %s", "grpclog Fatalf message")
if grpclog.V(0) {
grpclog.Fatalf("hello %s", "grpclog debug level json")
}
}
func TestGrpcLoggerLevel(t *testing.T) {
DefaultLogger.Caller = 1
DefaultLogger.Writer = &ConsoleWriter{ColorOutput: true, EndWithMessage: true}
DefaultLogger.Level = noLevel
var grpclog grpcLoggerV2 = DefaultLogger.Grpc(NewContext(nil).Str("tag", "hi sugar").Value())
notTest = false
grpclog.Info("hello", "grpclog Info message")
grpclog.Infoln("hello", "grpclog Infoln message")
grpclog.Infof("hello %s", "grpclog Infof message")
grpclog.Warning("hello", "grpclog Warning message")
grpclog.Warningln("hello", "grpclog Warningln message")
grpclog.Warningf("hello %s", "grpclog Warningf message")
grpclog.Error("hello", "grpclog Error message")
grpclog.Errorln("hello", "grpclog Errorln message")
grpclog.Errorf("hello %s", "grpclog Errorf message")
grpclog.Fatal("hello", "grpclog Fatal message")
grpclog.Fatalln("hello", "grpclog Fatalln message")
grpclog.Fatalf("hello %s", "grpclog Fatalf message")
}