summaryrefslogtreecommitdiff
path: root/plugins/logger/config.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-04-30 16:04:55 +0300
committerValery Piashchynski <[email protected]>2021-04-30 16:04:55 +0300
commit556477ca9df3fa2e5939057861314eabe5ce30ca (patch)
tree6bab1f99aa83c794060ab4c913d5ff62fef6882d /plugins/logger/config.go
parent5f451ffbba6b9758d61ba70ddd112a8e1570045a (diff)
- Make development log colored
- Remove old TODOs Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/logger/config.go')
-rw-r--r--plugins/logger/config.go30
1 files changed, 25 insertions, 5 deletions
diff --git a/plugins/logger/config.go b/plugins/logger/config.go
index c435e8be..d2236cac 100644
--- a/plugins/logger/config.go
+++ b/plugins/logger/config.go
@@ -40,7 +40,7 @@ type Config struct {
ErrorOutput []string `mapstructure:"errorOutput"`
}
-// ZapConfig converts config into Zap configuration.
+// BuildLogger converts config into Zap configuration.
func (cfg *Config) BuildLogger() (*zap.Logger, error) {
var zCfg zap.Config
switch strings.ToLower(cfg.Mode) {
@@ -49,7 +49,29 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) {
case "production":
zCfg = zap.NewProductionConfig()
case "development":
- zCfg = zap.NewDevelopmentConfig()
+ zCfg = zap.Config{
+ Level: zap.NewAtomicLevelAt(zap.DebugLevel),
+ Development: true,
+ Encoding: "console",
+ EncoderConfig: zapcore.EncoderConfig{
+ // Keys can be anything except the empty string.
+ TimeKey: "T",
+ LevelKey: "L",
+ NameKey: "N",
+ CallerKey: "C",
+ FunctionKey: zapcore.OmitKey,
+ MessageKey: "M",
+ StacktraceKey: "S",
+ LineEnding: zapcore.DefaultLineEnding,
+ EncodeLevel: ColoredLevelEncoder,
+ EncodeTime: zapcore.ISO8601TimeEncoder,
+ EncodeDuration: zapcore.StringDurationEncoder,
+ EncodeCaller: zapcore.ShortCallerEncoder,
+ EncodeName: ColoredNameEncoder,
+ },
+ OutputPaths: []string{"stderr"},
+ ErrorOutputPaths: []string{"stderr"},
+ }
case "raw":
zCfg = zap.Config{
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
@@ -98,12 +120,10 @@ func (cfg *Config) BuildLogger() (*zap.Logger, error) {
zCfg.ErrorOutputPaths = cfg.ErrorOutput
}
- // todo:
-
return zCfg.Build()
}
-// Initialize default logger
+// InitDefault Initialize default logger
func (cfg *Config) InitDefault() {
if cfg.Mode == "" {
cfg.Mode = "development"