From 02f4da047cf2166cb962a2f2b2799f8af25f26f9 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 20 Jun 2018 13:37:12 -0700 Subject: [PATCH] fixed: do the initial fields after initializing the config.. --- logutils/log.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/logutils/log.go b/logutils/log.go index 045740c..6428e75 100644 --- a/logutils/log.go +++ b/logutils/log.go @@ -51,12 +51,6 @@ func NewLogger(serviceName string, level string, format string, file string, fil var config zap.Config - if serviceName != "" { - config.InitialFields = map[string]interface{}{ - "service": serviceName, - } - } - switch format { case "json": config = zap.NewProductionConfig() @@ -102,6 +96,12 @@ func NewLogger(serviceName string, level string, format string, file string, fil panic(err) } + if serviceName != "" { + config.InitialFields = map[string]interface{}{ + "srv": serviceName, + } + } + // Pretty timestamp if prettyTimestamp { config.EncoderConfig.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {