mirror of
https://github.com/rs/zerolog
synced 2026-06-08 17:13:30 +00:00
Get BasicSampler(0), RandomSampler(0), and BurstSampler(0) to behave the same and not write anything (#696)
This commit is contained in:
@@ -47,6 +47,9 @@ type BasicSampler struct {
|
||||
// Sample implements the Sampler interface.
|
||||
func (s *BasicSampler) Sample(lvl Level) bool {
|
||||
n := s.N
|
||||
if n == 0 {
|
||||
return false
|
||||
}
|
||||
if n == 1 {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -28,6 +28,13 @@ var samplers = []struct {
|
||||
},
|
||||
100, 20, 20,
|
||||
},
|
||||
{
|
||||
"BasicSampler_0",
|
||||
func() Sampler {
|
||||
return &BasicSampler{N: 0}
|
||||
},
|
||||
100, 0, 0,
|
||||
},
|
||||
{
|
||||
"RandomSampler",
|
||||
func() Sampler {
|
||||
@@ -35,6 +42,13 @@ var samplers = []struct {
|
||||
},
|
||||
100, 10, 30,
|
||||
},
|
||||
{
|
||||
"RandomSampler_0",
|
||||
func() Sampler {
|
||||
return RandomSampler(0)
|
||||
},
|
||||
100, 0, 0,
|
||||
},
|
||||
{
|
||||
"BurstSampler",
|
||||
func() Sampler {
|
||||
@@ -42,6 +56,13 @@ var samplers = []struct {
|
||||
},
|
||||
100, 20, 20,
|
||||
},
|
||||
{
|
||||
"BurstSampler_0",
|
||||
func() Sampler {
|
||||
return &BurstSampler{Burst: 0, Period: time.Second}
|
||||
},
|
||||
100, 0, 0,
|
||||
},
|
||||
{
|
||||
"BurstSamplerNext",
|
||||
func() Sampler {
|
||||
|
||||
Reference in New Issue
Block a user