MCPcopy Create free account
hub / github.com/PostHog/duckgres / captureSlog

Function captureSlog

cmd/cache-proxy/proxy_test.go:80–86  ·  view source on GitHub ↗

captureSlog redirects slog.Default to a buffer for the duration of a test and returns the buffer + a restore function. Used by the forward-uncached logging tests to assert presence of the request/response log lines that were missing pre-PR (every PUT/POST through the proxy was a black hole).

(t *testing.T)

Source from the content-addressed store, hash-verified

78// logging tests to assert presence of the request/response log lines that
79// were missing pre-PR (every PUT/POST through the proxy was a black hole).
80//
81// The buffer must be concurrency-safe: proxy handlers log from goroutines
82// that outlive the request (e.g. the CONNECT close logger fires after both
83// tunnel legs finish), so test-goroutine String reads would race an
84// unsynchronized bytes.Buffer.
85func captureSlog(t *testing.T) (*syncBuffer, func()) {
86 t.Helper()
87 prev := slog.Default()
88 buf := &syncBuffer{}
89 slog.SetDefault(slog.New(slog.NewTextHandler(buf, &slog.HandlerOptions{Level: slog.LevelDebug})))

Calls

no outgoing calls

Tested by

no test coverage detected