| 455 | } |
| 456 | |
| 457 | func ExampleContext_Object() { |
| 458 | // User implements zerolog.LogObjectMarshaler |
| 459 | u := User{"John", 35, time.Time{}} |
| 460 | |
| 461 | log := zerolog.New(os.Stdout).With(). |
| 462 | Str("foo", "bar"). |
| 463 | Object("user", u). |
| 464 | Logger() |
| 465 | |
| 466 | log.Log().Msg("hello world") |
| 467 | |
| 468 | // Output: {"foo":"bar","user":{"name":"John","age":35,"created":"0001-01-01T00:00:00Z"},"message":"hello world"} |
| 469 | } |
| 470 | func ExampleContext_Objects() { |
| 471 | // User implements zerolog.LogObjectMarshaler |
| 472 | u := User{"John", 35, time.Time{}} |