-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
40 lines (32 loc) · 845 Bytes
/
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
package logger
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var Log *zap.Logger
func init() {
var err error
config := zap.NewProductionConfig()
encoderConfig := zap.NewProductionEncoderConfig()
encoderConfig.TimeKey = "timestamp"
encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
encoderConfig.StacktraceKey = ""
config.EncoderConfig = encoderConfig
Log, err = config.Build(zap.AddCallerSkip(1))
Log, err = zap.NewProduction(zap.AddCallerSkip(1))
if err != nil {
panic(err)
}
}
func Info(message string, fields ...zap.Field) {
Log.Info(message, fields...)
}
func Debug(message string, fields ...zap.Field) {
Log.Debug(message, fields...)
}
func Error(message string, fields ...zap.Field) {
Log.Error(message, fields...)
}
func Fatal(message string, fields ...zap.Field) {
Log.Fatal(message, fields...)
}