0.2.64 update
This commit is contained in:
@@ -2,6 +2,7 @@ package logging
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"log/slog"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -138,6 +139,22 @@ func TestBufferedLoggerRetainsStructuredEventsWithCursorPagination(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTailCursorReadDoesNotCopyTheRing(t *testing.T) {
|
||||
logger, buffer := NewBuffered(io.Discard, slog.LevelInfo, 5_000, FormatConsole)
|
||||
for range 5_000 {
|
||||
logger.Info("request complete")
|
||||
}
|
||||
allocations := testing.AllocsPerRun(100, func() {
|
||||
page := buffer.Events(5_000, 1_000)
|
||||
if len(page.Events) != 0 || page.HasMore {
|
||||
t.Fatalf("tail cursor unexpectedly returned events: %+v", page)
|
||||
}
|
||||
})
|
||||
if allocations > 2 {
|
||||
t.Fatalf("tail cursor allocated %.1f objects; the ring may be getting copied", allocations)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPersistentBufferRestoresTheRetainedTail(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "events.jsonl")
|
||||
var output bytes.Buffer
|
||||
|
||||
Reference in New Issue
Block a user