/
logger.go
54 lines (43 loc) · 1.11 KB
/
logger.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 logger
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
const (
DebugLevel = zap.DebugLevel // -1
InfoLevel = zap.InfoLevel // 0, default level
WarnLevel = zap.WarnLevel // 1
ErrorLevel = zap.ErrorLevel // 2
DPanicLevel = zap.DPanicLevel // 3, used in development log
PanicLevel = zap.PanicLevel // 4 logs a message, then panics
FatalLevel = zap.FatalLevel // 5 logs a message, then calls os.Exit(1)
)
type (
Field = zap.Field
Level = zapcore.Level
)
type Logger struct {
l *zap.Logger
level Level
}
func (l *Logger) Debug(msg string, fields ...Field) {
l.l.Debug(msg, fields...)
}
func (l *Logger) Info(msg string, fields ...Field) {
l.l.Info(msg, fields...)
}
func (l *Logger) Warn(msg string, fields ...Field) {
l.l.Warn(msg, fields...)
}
func (l *Logger) Error(msg string, fields ...Field) {
l.l.Error(msg, fields...)
}
func (l *Logger) DPanic(msg string, fields ...Field) {
l.l.DPanic(msg, fields...)
}
func (l *Logger) Panic(msg string, fields ...Field) {
l.l.Panic(msg, fields...)
}
func (l *Logger) Fatal(msg string, fields ...Field) {
l.l.Fatal(msg, fields...)
}