| 496 | // Output: {"foo":"bar","price":"$64.49","message":"hello world"} |
| 497 | } |
| 498 | func ExampleContext_Object() { |
| 499 | // User implements LogObjectMarshaler |
| 500 | u := User{"John", 35, time.Time{}} |
| 501 | |
| 502 | dst := bytes.Buffer{} |
| 503 | log := New(&dst).With(). |
| 504 | Str("foo", "bar"). |
| 505 | Object("user", u). |
| 506 | Logger() |
| 507 | |
| 508 | log.Log().Msg("hello world") |
| 509 | |
| 510 | fmt.Println(decodeIfBinaryToString(dst.Bytes())) |
| 511 | // Output: {"foo":"bar","user":{"name":"John","age":35,"created":"0001-01-01T00:00:00Z"},"message":"hello world"} |
| 512 | } |
| 513 | |
| 514 | func ExampleContext_Interface() { |
| 515 | obj := struct { |