| 483 | } |
| 484 | |
| 485 | func ExampleContext_ObjectsV() { |
| 486 | // User implements zerolog.LogObjectMarshaler |
| 487 | u := User{"John", 35, time.Time{}} |
| 488 | u2 := User{"Bono", 54, time.Time{}} |
| 489 | |
| 490 | log := zerolog.New(os.Stdout).With(). |
| 491 | Str("foo", "bar"). |
| 492 | ObjectsV("users", u, u2). // shows variadic version with distinct element arguments |
| 493 | Logger() |
| 494 | |
| 495 | log.Log().Msg("hello world") |
| 496 | |
| 497 | // Output: {"foo":"bar","users":[{"name":"John","age":35,"created":"0001-01-01T00:00:00Z"},{"name":"Bono","age":54,"created":"0001-01-01T00:00:00Z"}],"message":"hello world"} |
| 498 | } |
| 499 | |
| 500 | func ExampleContext_EmbedObject() { |
| 501 | price := Price{val: 6449, prec: 2, unit: "$"} |