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

Function ExampleContext_EmbedObject

binary_test.go:484–497  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

482}
483
484func ExampleContext_EmbedObject() {
485 price := Price{val: 6449, prec: 2, unit: "$"}
486
487 dst := bytes.Buffer{}
488 log := New(&dst).With().
489 Str("foo", "bar").
490 EmbedObject(price).
491 Logger()
492
493 log.Log().Msg("hello world")
494
495 fmt.Println(decodeIfBinaryToString(dst.Bytes()))
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{}}

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
EmbedObjectMethod · 0.45
StrMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected