forked from abdullin/cellar
-
Notifications
You must be signed in to change notification settings - Fork 1
/
logger.go
37 lines (31 loc) · 923 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
package cellar
import (
"fmt"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
func defaultLogger() *zap.Logger {
cfg := zap.Config{
Encoding: "json",
Level: zap.NewAtomicLevelAt(zap.WarnLevel),
OutputPaths: []string{"stdout"},
ErrorOutputPaths: []string{"stderr"},
EncoderConfig: zapcore.EncoderConfig{
MessageKey: "message",
LevelKey: "level",
EncodeLevel: zapcore.CapitalLevelEncoder,
TimeKey: "time",
EncodeTime: zapcore.ISO8601TimeEncoder,
CallerKey: "caller",
EncodeCaller: zapcore.ShortCallerEncoder,
},
}
logger, err := cfg.Build()
if err != nil {
// This panic should only occur during development, when reconfiguring the logger, or when
// switching between major version of zap.
panic(fmt.Sprintf("default logger incorrectly configured: %s", err.Error()))
}
logger = logger.With(zap.String("LOGGER", "CELLAR"))
return logger
}