MCPcopy
hub / github.com/uber-go/zap / writeContext

Method writeContext

zapcore/console_encoder.go:132–151  ·  view source on GitHub ↗
(line *buffer.Buffer, extra []Field)

Source from the content-addressed store, hash-verified

130}
131
132func (c consoleEncoder) writeContext(line *buffer.Buffer, extra []Field) {
133 context := c.jsonEncoder.Clone().(*jsonEncoder)
134 defer func() {
135 // putJSONEncoder assumes the buffer is still used, but we write out the buffer so
136 // we can free it.
137 context.buf.Free()
138 putJSONEncoder(context)
139 }()
140
141 addFields(context, extra)
142 context.closeOpenNamespaces()
143 if context.buf.Len() == 0 {
144 return
145 }
146
147 c.addSeparatorIfNecessary(line)
148 line.AppendByte('{')
149 line.Write(context.buf.Bytes())
150 line.AppendByte('}')
151}
152
153func (c consoleEncoder) addSeparatorIfNecessary(line *buffer.Buffer) {
154 if line.Len() > 0 {

Callers 1

EncodeEntryMethod · 0.95

Calls 10

putJSONEncoderFunction · 0.85
addFieldsFunction · 0.85
closeOpenNamespacesMethod · 0.80
AppendByteMethod · 0.80
BytesMethod · 0.80
CloneMethod · 0.65
WriteMethod · 0.65
FreeMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected