-
Notifications
You must be signed in to change notification settings - Fork 2
/
logger.go
49 lines (41 loc) · 1.08 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
package edgex
//
// Author: 陈哈哈 [email protected]
//
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var _ZapLoggerConfig = zap.Config{
Level: zap.NewAtomicLevelAt(zap.DebugLevel),
Development: false,
Encoding: "console",
EncoderConfig: zapcore.EncoderConfig{
// Keys can be anything except the empty string.
TimeKey: "T",
LevelKey: "L",
NameKey: "N",
MessageKey: "M",
CallerKey: "C",
LineEnding: zapcore.DefaultLineEnding,
EncodeLevel: zapcore.CapitalColorLevelEncoder,
EncodeTime: zapcore.ISO8601TimeEncoder,
EncodeDuration: zapcore.StringDurationEncoder,
EncodeCaller: zapcore.ShortCallerEncoder,
},
OutputPaths: []string{"stdout"},
ErrorOutputPaths: []string{"stderr"},
}
var ZapLogger = NewZapLogger()
var ZapSugarLogger = NewZapSugarLogger()
var log = ZapSugarLogger
func ZapLoggerConfig() zap.Config {
return _ZapLoggerConfig
}
func NewZapLogger() *zap.Logger {
logger, _ := _ZapLoggerConfig.Build()
return logger
}
func NewZapSugarLogger() *zap.SugaredLogger {
return ZapLogger.Sugar()
}