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

Function ExampleContext_Object

binary_test.go:498–512  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

496 // Output: {"foo":"bar","price":"$64.49","message":"hello world"}
497}
498func ExampleContext_Object() {
499 // User implements LogObjectMarshaler
500 u := User{"John", 35, time.Time{}}
501
502 dst := bytes.Buffer{}
503 log := New(&dst).With().
504 Str("foo", "bar").
505 Object("user", u).
506 Logger()
507
508 log.Log().Msg("hello world")
509
510 fmt.Println(decodeIfBinaryToString(dst.Bytes()))
511 // Output: {"foo":"bar","user":{"name":"John","age":35,"created":"0001-01-01T00:00:00Z"},"message":"hello world"}
512}
513
514func ExampleContext_Interface() {
515 obj := struct {

Callers

nothing calls this directly

Calls 10

NewFunction · 0.85
LoggerMethod · 0.80
WithMethod · 0.80
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