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

Function ExampleEvent_Interface

binary_test.go:329–346  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

327}
328
329func ExampleEvent_Interface() {
330 dst := bytes.Buffer{}
331 log := New(&dst)
332
333 obj := struct {
334 Name string `json:"name"`
335 }{
336 Name: "john",
337 }
338
339 log.Log().
340 Str("foo", "bar").
341 Interface("obj", obj).
342 Msg("hello world")
343
344 fmt.Println(decodeIfBinaryToString(dst.Bytes()))
345 // Output: {"foo":"bar","obj":{"name":"john"},"message":"hello world"}
346}
347
348func ExampleEvent_Dur() {
349 d := time.Duration(10 * time.Second)

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected