add logx.DisableStat() to disable stat logs (#893)

* add logx.DisableStat() to disable stat logs

* refactor logx code
This commit is contained in:
Kevin Wan
2021-08-10 16:55:38 +08:00
committed by GitHub
parent af1730079e
commit 872e75e10d
4 changed files with 46 additions and 25 deletions

View File

@@ -246,6 +246,17 @@ func TestDisable(t *testing.T) {
assert.Nil(t, Close())
}
func TestDisableStat(t *testing.T) {
DisableStat()
const message = "hello there"
writer := new(mockWriter)
statLog = writer
atomic.StoreUint32(&initialized, 1)
Stat(message)
assert.Equal(t, 0, writer.builder.Len())
}
func TestWithGzip(t *testing.T) {
fn := WithGzip()
var opt logOptions