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

Function ExampleContext_EmbedObject

log_example_test.go:500–510  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

498}
499
500func ExampleContext_EmbedObject() {
501 price := Price{val: 6449, prec: 2, unit: "$"}
502
503 log := zerolog.New(os.Stdout).With().
504 Str("foo", "bar").
505 EmbedObject(price).
506 Logger()
507
508 log.Log().Msg("hello world")
509 // Output: {"foo":"bar","price":"$64.49","message":"hello world"}
510}
511
512func ExampleContext_Interface() {
513 obj := struct {

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
LoggerMethod · 0.80
WithMethod · 0.80
MsgMethod · 0.80
LogMethod · 0.65
EmbedObjectMethod · 0.45
StrMethod · 0.45

Tested by

no test coverage detected