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

Function ExampleContext_Object

log_example_test.go:457–469  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

455}
456
457func ExampleContext_Object() {
458 // User implements zerolog.LogObjectMarshaler
459 u := User{"John", 35, time.Time{}}
460
461 log := zerolog.New(os.Stdout).With().
462 Str("foo", "bar").
463 Object("user", u).
464 Logger()
465
466 log.Log().Msg("hello world")
467
468 // Output: {"foo":"bar","user":{"name":"John","age":35,"created":"0001-01-01T00:00:00Z"},"message":"hello world"}
469}
470func ExampleContext_Objects() {
471 // User implements zerolog.LogObjectMarshaler
472 u := User{"John", 35, time.Time{}}

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected