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

Function TestSampling

log_test.go:803–813  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

801}
802
803func TestSampling(t *testing.T) {
804 out := &bytes.Buffer{}
805 log := New(out).Sample(&BasicSampler{N: 2})
806 log.Log().Int("i", 1).Msg("")
807 log.Log().Int("i", 2).Msg("")
808 log.Log().Int("i", 3).Msg("")
809 log.Log().Int("i", 4).Msg("")
810 if got, want := decodeIfBinaryToString(out.Bytes()), "{\"i\":1}\n{\"i\":3}\n"; got != want {
811 t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want)
812 }
813}
814
815func TestDisableSampling(t *testing.T) {
816 // Save original state

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
MsgMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
SampleMethod · 0.65
LogMethod · 0.65
IntMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected