package logging import ( "io" "testing" "golang.org/x/exp/slog" ) var _ io.Writer = (*testWriter)(nil) func NewWriter(tb testing.TB) io.Writer { tb.Helper() return testWriter{tb: tb} } func NewLogger(tb testing.TB) *slog.Logger { tb.Helper() return slog.New(slog.NewTextHandler(NewWriter(tb))) } type testWriter struct { tb testing.TB } func (t testWriter) Write(p []byte) (n int, err error) { t.tb.Log(string(p)) return len(p), nil }