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

Function TestWithReset

log_test.go:214–232  ·  log_test.go::TestWithReset
(t *testing.T)

Source from the content-addressed store, hash-verified

212}
213
214func TestWithReset(t *testing.T) {
215 out := &bytes.Buffer{}
216 ctx := New(out).With().
217 Str("string", "foo").
218 Stringer("stringer", net.IP{127, 0, 0, 1}).
219 Stringer("stringer_nil", nil).
220 Reset().
221 Bytes("bytes", []byte("bar")).
222 Hex("hex", []byte{0x12, 0xef}).
223 Uint64("uint64", 10).
224 Float64("float64", 12.30303).
225 Stack().
226 Ctx(context.Background())
227 log := ctx.Logger()
228 log.Log().Msg("")
229 if got, want := decodeIfBinaryToString(out.Bytes()), `{"bytes":"bar","hex":"12ef","uint64":10,"float64":12.30303}`+"\n"; got != want {
230 t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want)
231 }
232}
233
234func TestFieldsMap(t *testing.T) {
235 out := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 15

NewFunction · 0.85
ResetMethod · 0.80
WithMethod · 0.80
LoggerMethod · 0.80
MsgMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
LogMethod · 0.65
CtxMethod · 0.45
StackMethod · 0.45
Float64Method · 0.45
Uint64Method · 0.45
HexMethod · 0.45

Tested by

no test coverage detected