|
|
@ -42,18 +42,18 @@ func Test_logDuration(t *testing.T) {
|
|
|
|
buf := logtest.NewCollector(t)
|
|
|
|
buf := logtest.NewCollector(t)
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil)
|
|
|
|
logDuration(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil)
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), nil)
|
|
|
|
logDuration(context.Background(), "foo", "bar", timex.Now(), nil)
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"))
|
|
|
|
logDuration(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"))
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
@ -65,26 +65,26 @@ func Test_logDuration(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
DisableInfoLog()
|
|
|
|
DisableInfoLog()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), nil)
|
|
|
|
logDuration(context.Background(), "foo", "bar", timex.Now(), nil)
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil)
|
|
|
|
logDuration(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil)
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
DisableLog()
|
|
|
|
DisableLog()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), nil)
|
|
|
|
logDuration(context.Background(), "foo", "bar", timex.Now(), nil)
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil)
|
|
|
|
logDuration(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil)
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"))
|
|
|
|
logDuration(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"))
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
@ -94,37 +94,37 @@ func Test_logDurationWithDoc(t *testing.T) {
|
|
|
|
buf := logtest.NewCollector(t)
|
|
|
|
buf := logtest.NewCollector(t)
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
|
|
|
|
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, make(chan int))
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, make(chan int))
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, "{'json': ''}")
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, "{'json': ''}")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
assert.Contains(t, buf.String(), "json")
|
|
|
|
assert.Contains(t, buf.String(), "json")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), nil, make(chan int))
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), nil, make(chan int))
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), nil, "{'json': ''}")
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), nil, "{'json': ''}")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "json")
|
|
|
|
assert.Contains(t, buf.String(), "json")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"), make(chan int))
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"), make(chan int))
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"), "{'json': ''}")
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"), "{'json': ''}")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
@ -137,21 +137,21 @@ func Test_logDurationWithDoc(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
DisableInfoLog()
|
|
|
|
DisableInfoLog()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), nil, make(chan int))
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), nil, make(chan int))
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), nil, "{'json': ''}")
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), nil, "{'json': ''}")
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, make(chan int))
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, make(chan int))
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, "{'json': ''}")
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, "{'json': ''}")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
|
assert.Contains(t, buf.String(), "slow")
|
|
|
@ -159,29 +159,29 @@ func Test_logDurationWithDoc(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
DisableLog()
|
|
|
|
DisableLog()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), nil, make(chan int))
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), nil, make(chan int))
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), nil, "{'json': ''}")
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), nil, "{'json': ''}")
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, make(chan int))
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, make(chan int))
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, "{'json': ''}")
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now()-slowThreshold.Load()*2, nil, "{'json': ''}")
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
assert.Empty(t, buf.String())
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"), make(chan int))
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"), make(chan int))
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
|
|
|
|
|
|
|
|
|
buf.Reset()
|
|
|
|
buf.Reset()
|
|
|
|
logDurationWithDoc(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"), "{'json': ''}")
|
|
|
|
logDurationWithDocs(context.Background(), "foo", "bar", timex.Now(), errors.New("bar"), "{'json': ''}")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "foo")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "bar")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
|
assert.Contains(t, buf.String(), "fail")
|
|
|
|