Skip to content

Commit

Permalink
fixed: do the initial fields after initializing the config..
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Jun 20, 2018
1 parent 0cfeba2 commit 02f4da0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions logutils/log.go
Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 02f4da0

Please sign in to comment.