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

Function ExampleContext_Array_object

binary_test.go:449–466  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

447}
448
449func ExampleContext_Array_object() {
450 // Users implements LogArrayMarshaler
451 u := Users{
452 User{"John", 35, time.Time{}},
453 User{"Bob", 55, time.Time{}},
454 }
455
456 dst := bytes.Buffer{}
457 log := New(&dst).With().
458 Str("foo", "bar").
459 Array("users", u).
460 Logger()
461
462 log.Log().Msg("hello world")
463
464 fmt.Println(decodeIfBinaryToString(dst.Bytes()))
465 // 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"}
466}
467
468type Price struct {
469 val uint64

Callers

nothing calls this directly

Calls 10

NewFunction · 0.85
LoggerMethod · 0.80
WithMethod · 0.80
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