MCPcopy
hub / github.com/rs/zerolog / Array

Method Array

event.go:229–243  ·  view source on GitHub ↗

Array adds the field key with an array to the event context. Use e.CreateArray() to create the array or pass a type that implement the LogArrayMarshaler interface.

(key string, arr LogArrayMarshaler)

Source from the content-addressed store, hash-verified

227// Use e.CreateArray() to create the array or pass a type that
228// implement the LogArrayMarshaler interface.
229func (e *Event) Array(key string, arr LogArrayMarshaler) *Event {
230 if e == nil {
231 return e
232 }
233 e.buf = enc.AppendKey(e.buf, key)
234 var a *Array
235 if aa, ok := arr.(*Array); ok {
236 a = aa
237 } else {
238 a = e.CreateArray()
239 arr.MarshalZerologArray(a)
240 }
241 e.buf = a.write(e.buf)
242 return e
243}
244
245func (e *Event) appendObject(obj LogObjectMarshaler) {
246 e.buf = enc.AppendBeginMarker(e.buf)

Callers 11

ErrsMethod · 0.95
TestEvent_WithNilEventFunction · 0.95
ExampleEvent_ArrayFunction · 0.45
ExampleContext_ArrayFunction · 0.45
ExampleEvent_ArrayFunction · 0.45
ExampleContext_ArrayFunction · 0.45
BenchmarkLogArrayObjectFunction · 0.45

Calls 4

CreateArrayMethod · 0.95
writeMethod · 0.95
AppendKeyMethod · 0.65
MarshalZerologArrayMethod · 0.65

Tested by 10

TestEvent_WithNilEventFunction · 0.76
ExampleEvent_ArrayFunction · 0.36
ExampleContext_ArrayFunction · 0.36
ExampleEvent_ArrayFunction · 0.36
ExampleContext_ArrayFunction · 0.36
BenchmarkLogArrayObjectFunction · 0.36