-
Notifications
You must be signed in to change notification settings - Fork 0
/
overlogger_example_test.go
157 lines (111 loc) · 3.79 KB
/
overlogger_example_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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package zero_mdc_log
import (
"github.com/rs/zerolog"
"os"
)
func ExampleOverlog_New() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
MDC().Set("x-agent-name", "trendyol")
SetGlobalFields([]string{"x-correlation-id", "x-agent-name"})
Log().OInfo("hello world")
// Output: {"level":"info","x-agent-name":"trendyol","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Trace() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Trace("hello world")
// Output: {"level":"trace","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Tracef() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Tracef("hello %s", "world")
// Output: {"level":"trace","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Debug() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().ODebug("hello world")
// Output: {"level":"debug","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Debugf() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Debugf("hello %s", "world")
// Output: {"level":"debug","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Info() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().OInfo("hello world")
// Output: {"level":"info","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Infof() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Infof("hello %s", "world")
// Output: {"level":"info","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Warn() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Warn("hello world")
// Output: {"level":"warn","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Warnf() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Warnf("hello %s", "world")
// Output: {"level":"warn","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Error() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().OError("hello world")
// Output: {"level":"error","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Errorf() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Errorf("hello %s", "world")
// Output: {"level":"error","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Log() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Log("hello world")
// Output: {"x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Logf() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Logf("hello %s", "world")
// Output: {"x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Print() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Print("hello world")
// Output: {"level":"debug","x-correlation-id":"1234","message":"hello world"}
}
func ExampleOverlog_Printf() {
New(zerolog.New(os.Stdout))
MDC().Set("x-correlation-id", "1234")
AddGlobalFields("x-correlation-id")
Log().Printf("hello %s", "world")
// Output: {"level":"debug","x-correlation-id":"1234","message":"hello world"}
}