(t *testing.T)
| 813 | } |
| 814 | |
| 815 | func TestDisableSampling(t *testing.T) { |
| 816 | // Save original state |
| 817 | original := samplingDisabled() |
| 818 | defer DisableSampling(original) |
| 819 | |
| 820 | out := &bytes.Buffer{} |
| 821 | log := New(out).Sample(&BasicSampler{N: 2}) |
| 822 | |
| 823 | // Enable sampling disable |
| 824 | DisableSampling(true) |
| 825 | |
| 826 | log.Log().Int("i", 1).Msg("") |
| 827 | log.Log().Int("i", 2).Msg("") |
| 828 | log.Log().Int("i", 3).Msg("") |
| 829 | log.Log().Int("i", 4).Msg("") |
| 830 | |
| 831 | // All messages should be logged since sampling is disabled |
| 832 | if got, want := decodeIfBinaryToString(out.Bytes()), "{\"i\":1}\n{\"i\":2}\n{\"i\":3}\n{\"i\":4}\n"; got != want { |
| 833 | t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want) |
| 834 | } |
| 835 | } |
| 836 | |
| 837 | func TestDiscard(t *testing.T) { |
| 838 | out := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected