-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.go
42 lines (34 loc) · 917 Bytes
/
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
package log
import (
"go.uber.org/zap"
)
// ZapLoggerWapper zap logger wapper
type ZapLoggerWapper struct {
logger *zap.SugaredLogger
}
// NewZapLoggerWrapper return a pointer to ZapLoggerWapper
func NewZapLoggerWrapper(logger *zap.SugaredLogger) *ZapLoggerWapper {
return &ZapLoggerWapper{
logger: logger,
}
}
// With return a new Logger with context
func (z *ZapLoggerWapper) With(ctx ...interface{}) Logger {
return NewZapLoggerWrapper(z.logger.With(ctx...))
}
// Debug ...
func (z *ZapLoggerWapper) Debug(msg string, ctx ...interface{}) {
z.logger.Debugw(msg, ctx...)
}
// Info ...
func (z *ZapLoggerWapper) Info(msg string, ctx ...interface{}) {
z.logger.Infow(msg, ctx...)
}
// Warn ...
func (z *ZapLoggerWapper) Warn(msg string, ctx ...interface{}) {
z.logger.Warnw(msg, ctx...)
}
// Error ...
func (z *ZapLoggerWapper) Error(msg string, ctx ...interface{}) {
z.logger.Errorw(msg, ctx...)
}