| 447 | } |
| 448 | |
| 449 | func 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 | |
| 468 | type Price struct { |
| 469 | val uint64 |