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

Function ExampleEvent_Array_object

binary_test.go:260–277  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

258}
259
260func ExampleEvent_Array_object() {
261 dst := bytes.Buffer{}
262 log := New(&dst)
263
264 // Users implements LogArrayMarshaler
265 u := Users{
266 User{"John", 35, time.Time{}},
267 User{"Bob", 55, time.Time{}},
268 }
269
270 log.Log().
271 Str("foo", "bar").
272 Array("users", u).
273 Msg("hello world")
274
275 fmt.Println(decodeIfBinaryToString(dst.Bytes()))
276 // Output: {"foo":"bar","users":[{"name":"John","age":35,"created":"0001-01-01T00:00:00Z"},{"name":"Bob","age":55,"created":"0001-01-01T00:00:00Z"}],"message":"hello world"}
277}
278
279func ExampleEvent_Object() {
280 dst := bytes.Buffer{}

Callers

nothing calls this directly

Calls 8

NewFunction · 0.85
MsgMethod · 0.80
PrintlnMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
LogMethod · 0.65
ArrayMethod · 0.45
StrMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected