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

Function ExampleContext_Fields_map

log_example_test.go:613–627  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

611}
612
613func ExampleContext_Fields_map() {
614 fields := map[string]interface{}{
615 "bar": "baz",
616 "n": 1,
617 }
618
619 log := zerolog.New(os.Stdout).With().
620 Str("foo", "bar").
621 Fields(fields).
622 Logger()
623
624 log.Log().Msg("hello world")
625
626 // Output: {"foo":"bar","bar":"baz","n":1,"message":"hello world"}
627}
628
629func ExampleContext_Fields_slice() {
630 fields := []interface{}{

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected