-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzlog.go
288 lines (238 loc) · 7.41 KB
/
zlog.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
package zlog
import "go.uber.org/zap"
type ZapLogger struct {
ConfigPath string
Log *zap.Logger
Sugar *zap.SugaredLogger
}
// Logger is the global variable for the object of lager.Logger
var Logger LoggerGlobal
type logger struct {
ConfigPath string
Log *zap.Logger
Sugar *zap.SugaredLogger
}
func (l *logger) Debugf(format string, args ...interface{}) {
l.Sugar.Debugf(format, args)
}
func (l *logger) Infof(format string, args ...interface{}) {
l.Sugar.Infof(format, args)
}
func (l *logger) Debug(args ...interface{}) {
l.Sugar.Debug(args)
}
func (l *logger) Info(args ...interface{}) {
l.Sugar.Info(args)
}
func (l *logger) Warn(args ...interface{}) {
l.Sugar.Warn(args)
}
func (l *logger) Error(args ...interface{}) {
l.Sugar.Error(args)
}
func (l *logger) DPanic(args ...interface{}) {
l.Sugar.DPanic(args)
}
func (l *logger) Panic(args ...interface{}) {
l.Sugar.Panic(args)
}
func (l *logger) Fatal(args ...interface{}) {
l.Sugar.Fatal(args)
}
func (l *logger) Warnf(template string, args ...interface{}) {
l.Sugar.Warnf(template, args)
}
func (l *logger) Errorf(template string, args ...interface{}) {
l.Sugar.Errorf(template, args)
}
func (l *logger) DPanicf(template string, args ...interface{}) {
l.Sugar.DPanicf(template, args)
}
func (l *logger) Panicf(template string, args ...interface{}) {
l.Sugar.Panicf(template, args)
}
func (l *logger) Fatalf(template string, args ...interface{}) {
l.Sugar.Fatalf(template, args)
}
func (l *logger) Debugw(msg string, keysAndValues ...interface{}) {
l.Sugar.Debugw(msg, keysAndValues)
}
func (l *logger) Infow(msg string, keysAndValues ...interface{}) {
l.Sugar.Infow(msg, keysAndValues)
}
func (l *logger) Warnw(msg string, keysAndValues ...interface{}) {
l.Sugar.Warnw(msg, keysAndValues)
}
func (l *logger) Errorw(msg string, keysAndValues ...interface{}) {
l.Sugar.Errorw(msg, keysAndValues)
}
func (l *logger) DPanicw(msg string, keysAndValues ...interface{}) {
l.Sugar.DPanicw(msg, keysAndValues)
}
func (l *logger) Panicw(msg string, keysAndValues ...interface{}) {
l.Sugar.Panicw(msg, keysAndValues)
}
func (l *logger) Fatalw(msg string, keysAndValues ...interface{}) {
l.Sugar.Fatalw(msg, keysAndValues)
}
func (l *logger) Sync() error {
panic("implement me")
}
//Logger is a interface
type LoggerGlobal interface {
Debug(args ...interface{})
Info(args ...interface{})
Warn(args ...interface{})
Error(args ...interface{})
DPanic(args ...interface{})
Panic(args ...interface{})
Fatal(args ...interface{})
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(template string, args ...interface{})
Errorf(template string, args ...interface{})
DPanicf(template string, args ...interface{})
Panicf(template string, args ...interface{})
Fatalf(template string, args ...interface{})
Debugw(msg string, keysAndValues ...interface{})
Infow(msg string, keysAndValues ...interface{})
Warnw(msg string, keysAndValues ...interface{})
Errorw(msg string, keysAndValues ...interface{})
DPanicw(msg string, keysAndValues ...interface{})
Panicw(msg string, keysAndValues ...interface{})
Fatalw(msg string, keysAndValues ...interface{})
Sync() error
}
// Deprecated
// newLog new log
func newLogger(configPath string, log *zap.Logger, sugar *zap.SugaredLogger) LoggerGlobal {
return &logger{
ConfigPath: configPath,
Log: log,
Sugar: sugar,
}
}
// Deprecated
// Debug uses fmt.Sprint to construct and log a message.
func Debug(args ...interface{}) {
Logger.Debug(args)
}
// Deprecated
// Info uses fmt.Sprint to construct and log a message.
func Info(args ...interface{}) {
Logger.Info(args)
}
// Deprecated
// Warn uses fmt.Sprint to construct and log a message.
func Warn(args ...interface{}) {
Logger.Warn(args)
}
// Deprecated
// Error uses fmt.Sprint to construct and log a message.
func Error(args ...interface{}) {
Logger.Error(args)
}
// Deprecated
// DPanic uses fmt.Sprint to construct and log a message. In development, the
// logger then panics. (See zapcore.DPanicLevel for details.)
func DPanic(args ...interface{}) {
Logger.DPanic(args)
}
// Deprecated
// Panic uses fmt.Sprint to construct and log a message, then panics.
func Panic(args ...interface{}) {
Logger.Panic(args)
}
// Deprecated
// Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
func Fatal(args ...interface{}) {
Logger.Fatal(args)
}
// Deprecated
// Debugf uses fmt.Sprintf to log a templated message.
func Debugf(format string, args ...interface{}) {
Sugared.Debugf(format, args)
//Logger.Debugf(format, args...)
}
// Deprecated
// Infof uses fmt.Sprintf to log a templated message.
func Infof(format string, args ...interface{}) {
Logger.Infof(format, args...)
}
// Deprecated
// Warnf uses fmt.Sprintf to log a templated message.
func Warnf(template string, args ...interface{}) {
Logger.Warnf(template, args)
}
// Deprecated
// Errorf uses fmt.Sprintf to log a templated message.
func Errorf(template string, args ...interface{}) {
Logger.Errorf(template, args)
}
// Deprecated
// DPanicf uses fmt.Sprintf to log a templated message. In development, the
// logger then panics. (See zapcore.DPanicLevel for details.)
func DPanicf(template string, args ...interface{}) {
Logger.DPanicf(template, args)
}
// Deprecated
// Panicf uses fmt.Sprintf to log a templated message, then panics.
func Panicf(template string, args ...interface{}) {
Logger.Panicf(template, args)
}
// Deprecated
// Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
func Fatalf(template string, args ...interface{}) {
Logger.Fatalf(template, args)
}
// Deprecated
// Debugw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
//
// When debug-level logging is disabled, this is much faster than
// s.With(keysAndValues).Debug(msg)
func Debugw(msg string, keysAndValues ...interface{}) {
Logger.Debugw(msg, keysAndValues)
}
// Deprecated
// Infow logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
func Infow(msg string, keysAndValues ...interface{}) {
Logger.Infow(msg, keysAndValues)
}
// Deprecated
// Warnw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
func Warnw(msg string, keysAndValues ...interface{}) {
Logger.Warnw(msg, keysAndValues)
}
// Deprecated
// Errorw logs a message with some additional context. The variadic key-value
// pairs are treated as they are in With.
func Errorw(msg string, keysAndValues ...interface{}) {
Logger.Errorw(msg, keysAndValues)
}
// Deprecated
// DPanicw logs a message with some additional context. In development, the
// logger then panics. (See DPanicLevel for details.) The variadic key-value
// pairs are treated as they are in With.
func DPanicw(msg string, keysAndValues ...interface{}) {
Logger.DPanicw(msg, keysAndValues)
}
// Deprecated
// Panicw logs a message with some additional context, then panics. The
// variadic key-value pairs are treated as they are in With.
func Panicw(msg string, keysAndValues ...interface{}) {
Logger.Panicw(msg, keysAndValues)
}
// Deprecated
// Fatalw logs a message with some additional context, then calls os.Exit. The
// variadic key-value pairs are treated as they are in With.
func Fatalw(msg string, keysAndValues ...interface{}) {
Logger.Fatalw(msg, keysAndValues)
}
// Deprecated
// Sync flushes any buffered log entries.
func Sync() error {
return Logger.Sync()
}