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

Function ExampleContext_ObjectsV

log_example_test.go:485–498  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

483}
484
485func ExampleContext_ObjectsV() {
486 // User implements zerolog.LogObjectMarshaler
487 u := User{"John", 35, time.Time{}}
488 u2 := User{"Bono", 54, time.Time{}}
489
490 log := zerolog.New(os.Stdout).With().
491 Str("foo", "bar").
492 ObjectsV("users", u, u2). // shows variadic version with distinct element arguments
493 Logger()
494
495 log.Log().Msg("hello world")
496
497 // Output: {"foo":"bar","users":[{"name":"John","age":35,"created":"0001-01-01T00:00:00Z"},{"name":"Bono","age":54,"created":"0001-01-01T00:00:00Z"}],"message":"hello world"}
498}
499
500func ExampleContext_EmbedObject() {
501 price := Price{val: 6449, prec: 2, unit: "$"}

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected