MCPcopy
hub / github.com/rs/zerolog / ExampleEvent_Object

Function ExampleEvent_Object

binary_test.go:279–293  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

277}
278
279func 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
295func ExampleContext_Objects() {
296 // In go, arrays are type invariant so even if you have a variable u of type []User array and User implements

Callers

nothing calls this directly

Calls 8

NewFunction · 0.85
MsgMethod · 0.80
PrintlnMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
LogMethod · 0.65
ObjectMethod · 0.45
StrMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected