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

Function ExampleContext_Array

binary_test.go:433–447  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

431}
432
433func ExampleContext_Array() {
434 dst := bytes.Buffer{}
435 ctx := New(&dst).With().
436 Str("foo", "bar")
437
438 logger := ctx.Array("array", ctx.CreateArray().
439 Str("baz").
440 Int(1),
441 ).Logger()
442
443 logger.Log().Msg("hello world")
444
445 fmt.Println(decodeIfBinaryToString(dst.Bytes()))
446 // Output: {"foo":"bar","array":["baz",1],"message":"hello world"}
447}
448
449func ExampleContext_Array_object() {
450 // Users implements LogArrayMarshaler

Callers

nothing calls this directly

Calls 12

NewFunction · 0.85
WithMethod · 0.80
LoggerMethod · 0.80
MsgMethod · 0.80
PrintlnMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
LogMethod · 0.65
StrMethod · 0.45
ArrayMethod · 0.45
IntMethod · 0.45
CreateArrayMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected