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

Function ExampleContext_Array_object

log_example_test.go:440–455  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

438}
439
440func ExampleContext_Array_object() {
441 // Users implements zerolog.LogArrayMarshaler
442 u := Users{
443 User{"John", 35, time.Time{}},
444 User{"Bob", 55, time.Time{}},
445 }
446
447 log := zerolog.New(os.Stdout).With().
448 Str("foo", "bar").
449 Array("users", u).
450 Logger()
451
452 log.Log().Msg("hello world")
453
454 // Output: {"foo":"bar","users":[{"name":"John","age":35,"created":"0001-01-01T00:00:00Z"},{"name":"Bob","age":55,"created":"0001-01-01T00:00:00Z"}],"message":"hello world"}
455}
456
457func ExampleContext_Object() {
458 // User implements zerolog.LogObjectMarshaler

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected