| 277 | } |
| 278 | |
| 279 | func ExampleEvent_Object() { |
| 280 | dst := bytes.Buffer{} |
| 281 | log := New(&dst) |
| 282 | |
| 283 | // User implements LogObjectMarshaler |
| 284 | u := User{"John", 35, time.Time{}} |
| 285 | |
| 286 | log.Log(). |
| 287 | Str("foo", "bar"). |
| 288 | Object("user", u). |
| 289 | Msg("hello world") |
| 290 | |
| 291 | fmt.Println(decodeIfBinaryToString(dst.Bytes())) |
| 292 | // Output: {"foo":"bar","user":{"name":"John","age":35,"created":"0001-01-01T00:00:00Z"},"message":"hello world"} |
| 293 | } |
| 294 | |
| 295 | func ExampleContext_Objects() { |
| 296 | // In go, arrays are type invariant so even if you have a variable u of type []User array and User implements |