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

Function ExampleContext_Interface

log_example_test.go:512–527  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

510}
511
512func ExampleContext_Interface() {
513 obj := struct {
514 Name string `json:"name"`
515 }{
516 Name: "john",
517 }
518
519 log := zerolog.New(os.Stdout).With().
520 Str("foo", "bar").
521 Interface("obj", obj).
522 Logger()
523
524 log.Log().Msg("hello world")
525
526 // Output: {"foo":"bar","obj":{"name":"john"},"message":"hello world"}
527}
528
529func ExampleContext_Dur() {
530 d := 10 * time.Second

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected