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

Method Objects

event.go:271–284  ·  view source on GitHub ↗

Objects adds the field key with objs as an array of objects that implement the LogObjectMarshaler interface to the event. This is the array version that accepts a slice of LogObjectMarshaler objects.

(key string, objs []LogObjectMarshaler)

Source from the content-addressed store, hash-verified

269//
270// This is the array version that accepts a slice of LogObjectMarshaler objects.
271func (e *Event) Objects(key string, objs []LogObjectMarshaler) *Event {
272 if e == nil {
273 return e
274 }
275 e.buf = enc.AppendArrayStart(enc.AppendKey(e.buf, key))
276 for i, obj := range objs {
277 e.buf = appendObject(e.buf, obj, e.stack, e.ctx, e.ch)
278 if i < (len(objs) - 1) {
279 e.buf = enc.AppendArrayDelim(e.buf)
280 }
281 }
282 e.buf = enc.AppendArrayEnd(e.buf)
283 return e
284}
285
286// ObjectsV adds the field key with objs as an array of objects that
287// implement the LogObjectMarshaler interface to the event.

Callers 13

ObjectsVMethod · 0.95
TestEvent_WithNilEventFunction · 0.95
ExampleEvent_ObjectsFunction · 0.45
ExampleContext_ObjectsFunction · 0.45
TestWithPluralsFunction · 0.45
TestFieldsArrayNilFunction · 0.45
TestFieldsArrayEmptyFunction · 0.45
TestFieldsDisabledFunction · 0.45
ExampleContext_ObjectsFunction · 0.45
BenchmarkLogFieldTypeFunction · 0.45

Calls 5

appendObjectFunction · 0.85
AppendArrayStartMethod · 0.65
AppendKeyMethod · 0.65
AppendArrayDelimMethod · 0.65
AppendArrayEndMethod · 0.65

Tested by 12

TestEvent_WithNilEventFunction · 0.76
ExampleEvent_ObjectsFunction · 0.36
ExampleContext_ObjectsFunction · 0.36
TestWithPluralsFunction · 0.36
TestFieldsArrayNilFunction · 0.36
TestFieldsArrayEmptyFunction · 0.36
TestFieldsDisabledFunction · 0.36
ExampleContext_ObjectsFunction · 0.36
BenchmarkLogFieldTypeFunction · 0.36