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

Function ExampleEvent_Array_object

log_example_test.go:262–277  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

260}
261
262func ExampleEvent_Array_object() {
263 log := zerolog.New(os.Stdout)
264
265 // Users implements zerolog.LogArrayMarshaler
266 u := Users{
267 User{"John", 35, time.Time{}},
268 User{"Bob", 55, time.Time{}},
269 }
270
271 log.Log().
272 Str("foo", "bar").
273 Array("users", u).
274 Msg("hello world")
275
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 log := zerolog.New(os.Stdout)

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
MsgMethod · 0.80
LogMethod · 0.65
ArrayMethod · 0.45
StrMethod · 0.45

Tested by

no test coverage detected