-
Notifications
You must be signed in to change notification settings - Fork 7
/
log.go
211 lines (166 loc) · 6.26 KB
/
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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
package log
// Fields represents a map of key-value pairs where the value can be any Go
// type. The value must be able to be converted to a string.
type Fields map[string]interface{}
// Logger is an interface for Logging
type Logger interface {
// Trace logs a message at the Trace level
Trace(msg ...interface{})
// Tracef formats a message according to a format specifier and logs the
// message at the Trace level
Tracef(template string, args ...interface{})
// Tracew logs a message at the Trace level along with some additional
// context (key-value pairs)
Tracew(msg string, fields Fields)
// Debug logs a message at the Debug level
Debug(msg ...interface{})
// Debugf formats a message according to a format specifier and logs the
// message at the Debug level
Debugf(template string, args ...interface{})
// Debugw logs a message at the Debug level along with some additional
// context (key-value pairs)
Debugw(msg string, fields Fields)
// Info logs a message at the Info level
Info(msg ...interface{})
// Infof formats a message according to a format specifier and logs the
// message at the Info level
Infof(template string, args ...interface{})
// Infow logs a message at the Info level along with some additional
// context (key-value pairs)
Infow(msg string, fields Fields)
// Warn logs a message at the Warn level
Warn(msg ...interface{})
// Warnf formats a message according to a format specifier and logs the
// message at the Warning level
Warnf(template string, args ...interface{})
// Warnw logs a message at the Warning level along with some additional
// context (key-value pairs)
Warnw(msg string, fields Fields)
// Error logs a message at the Error level
Error(msg ...interface{})
// Errorf formats a message according to a format specifier and logs the
// message at the Error level
Errorf(template string, args ...interface{})
// Errorw logs a message at the Error level along with some additional
// context (key-value pairs)
Errorw(msg string, fields Fields)
// Panic logs a message at the Panic level and panics
Panic(msg ...interface{})
// Panicf formats a message according to a format specifier and logs the
// message at the Panic level and then panics
Panicf(template string, args ...interface{})
// Panicw logs a message at the Panic level along with some additional
// context (key-value pairs) and then panics
Panicw(msg string, fields Fields)
// Fatal logs a message at the Fatal level and exists the application
Fatal(msg ...interface{})
// Fatalf formats a message according to a format specifier and logs the
// message at the Fatal level and exits the application
Fatalf(template string, args ...interface{})
// Fatalw logs a message at the Fatal level along with some additional
// context (key-value pairs) and exits the application
Fatalw(msg string, fields Fields)
}
// Current contains the logger used for the package level logging functions
var Current Logger
func init() {
Current = NewStandard()
}
// Trace logs a message at the Trace level
func Trace(msg ...interface{}) {
Current.Trace(msg...)
}
// Tracef formats a message according to a format specifier and logs the
// message at the Trace level
func Tracef(template string, args ...interface{}) {
Current.Tracef(template, args...)
}
// Tracew logs a message at the Trace level along with some additional
// context (key-value pairs)
func Tracew(msg string, fields Fields) {
Current.Tracew(msg, fields)
}
// Debug logs a message at the Debug level
func Debug(msg ...interface{}) {
Current.Debug(msg...)
}
// Debugf formats a message according to a format specifier and logs the
// message at the Debug level
func Debugf(template string, args ...interface{}) {
Current.Debugf(template, args...)
}
// Debugw logs a message at the Debug level along with some additional
// context (key-value pairs)
func Debugw(msg string, fields Fields) {
Current.Debugw(msg, fields)
}
// Info logs a message at the Info level
func Info(msg ...interface{}) {
Current.Info(msg...)
}
// Infof formats a message according to a format specifier and logs the
// message at the Info level
func Infof(template string, args ...interface{}) {
Current.Infof(template, args...)
}
// Infow logs a message at the Info level along with some additional
// context (key-value pairs)
func Infow(msg string, fields Fields) {
Current.Infow(msg, fields)
}
// Warn logs a message at the Warn level
func Warn(msg ...interface{}) {
Current.Warn(msg...)
}
// Warnf formats a message according to a format specifier and logs the
// message at the Warning level
func Warnf(template string, args ...interface{}) {
Current.Warnf(template, args...)
}
// Warnw logs a message at the Warning level along with some additional
// context (key-value pairs)
func Warnw(msg string, fields Fields) {
Current.Warnw(msg, fields)
}
// Error logs a message at the Error level
func Error(msg ...interface{}) {
Current.Error(msg...)
}
// Errorf formats a message according to a format specifier and logs the
// message at the Error level
func Errorf(template string, args ...interface{}) {
Current.Errorf(template, args...)
}
// Errorw logs a message at the Error level along with some additional
// context (key-value pairs)
func Errorw(msg string, fields Fields) {
Current.Errorw(msg, fields)
}
// Panic logs a message at the Panic level and panics
func Panic(msg ...interface{}) {
Current.Panic(msg...)
}
// Panicf formats a message according to a format specifier and logs the
// message at the Panic level and then panics
func Panicf(template string, args ...interface{}) {
Current.Panicf(template, args...)
}
// Panicw logs a message at the Panic level along with some additional
// context (key-value pairs) and then panics
func Panicw(msg string, fields Fields) {
Current.Panicw(msg, fields)
}
// Fatal logs a message at the Fatal level and exists the application
func Fatal(msg ...interface{}) {
Current.Fatal(msg...)
}
// Fatalf formats a message according to a format specifier and logs the
// message at the Fatal level and exits the application
func Fatalf(template string, args ...interface{}) {
Current.Fatalf(template, args...)
}
// Fatalw logs a message at the Fatal level along with some additional
// context (key-value pairs) and exits the application
func Fatalw(msg string, fields Fields) {
Current.Fatalw(msg, fields)
}