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

Method Array

context.go:60–70  ·  view source on GitHub ↗

Array adds the field key with an array to the event context. Use c.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

58// Use c.CreateArray() to create the array or pass a type that
59// implement the LogArrayMarshaler interface.
60func (c Context) Array(key string, arr LogArrayMarshaler) Context {
61 c.l.context = enc.AppendKey(c.l.context, key)
62 if arr, ok := arr.(*Array); ok {
63 c.l.context = arr.write(c.l.context)
64 return c
65 }
66 a := c.CreateArray()
67 arr.MarshalZerologArray(a)
68 c.l.context = a.write(c.l.context)
69 return c
70}
71
72// Object marshals an object that implement the LogObjectMarshaler interface.
73func (c Context) Object(key string, obj LogObjectMarshaler) Context {

Callers 1

ErrsMethod · 0.95

Calls 4

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

Tested by

no test coverage detected