[VOL-4290] Voltha go library updates for gRPC migration
Change-Id: I1aa2774beb6b7ed7419bc45aeb53fcae8a8ecda0
diff --git a/vendor/go.uber.org/zap/zapcore/console_encoder.go b/vendor/go.uber.org/zap/zapcore/console_encoder.go
index b787596..2307af4 100644
--- a/vendor/go.uber.org/zap/zapcore/console_encoder.go
+++ b/vendor/go.uber.org/zap/zapcore/console_encoder.go
@@ -56,6 +56,10 @@
// encoder configuration, it will omit any element whose key is set to the empty
// string.
func NewConsoleEncoder(cfg EncoderConfig) Encoder {
+ if cfg.ConsoleSeparator == "" {
+ // Use a default delimiter of '\t' for backwards compatibility
+ cfg.ConsoleSeparator = "\t"
+ }
return consoleEncoder{newJSONEncoder(cfg, true)}
}
@@ -89,12 +93,17 @@
nameEncoder(ent.LoggerName, arr)
}
- if ent.Caller.Defined && c.CallerKey != "" && c.EncodeCaller != nil {
- c.EncodeCaller(ent.Caller, arr)
+ if ent.Caller.Defined {
+ if c.CallerKey != "" && c.EncodeCaller != nil {
+ c.EncodeCaller(ent.Caller, arr)
+ }
+ if c.FunctionKey != "" {
+ arr.AppendString(ent.Caller.Function)
+ }
}
for i := range arr.elems {
if i > 0 {
- line.AppendByte('\t')
+ line.AppendString(c.ConsoleSeparator)
}
fmt.Fprint(line, arr.elems[i])
}
@@ -102,7 +111,7 @@
// Add the message itself.
if c.MessageKey != "" {
- c.addTabIfNecessary(line)
+ c.addSeparatorIfNecessary(line)
line.AppendString(ent.Message)
}
@@ -126,7 +135,12 @@
func (c consoleEncoder) writeContext(line *buffer.Buffer, extra []Field) {
context := c.jsonEncoder.Clone().(*jsonEncoder)
- defer context.buf.Free()
+ defer func() {
+ // putJSONEncoder assumes the buffer is still used, but we write out the buffer so
+ // we can free it.
+ context.buf.Free()
+ putJSONEncoder(context)
+ }()
addFields(context, extra)
context.closeOpenNamespaces()
@@ -134,14 +148,14 @@
return
}
- c.addTabIfNecessary(line)
+ c.addSeparatorIfNecessary(line)
line.AppendByte('{')
line.Write(context.buf.Bytes())
line.AppendByte('}')
}
-func (c consoleEncoder) addTabIfNecessary(line *buffer.Buffer) {
+func (c consoleEncoder) addSeparatorIfNecessary(line *buffer.Buffer) {
if line.Len() > 0 {
- line.AppendByte('\t')
+ line.AppendString(c.ConsoleSeparator)
}
}