Source File
testlog.go
Belonging Package
github.com/pancsta/d2/internal/testlog
// Package testlog adapts testing-style loggers to slog.package testlogimport ()// TB is the subset of testing.TB needed to write logs to a test.type TB interface {Helper()Log(args ...any)}type tbWriter struct {tb TB}func ( *tbWriter) ( []byte) ( int, error) {.tb.Helper().tb.Log(string())return len(), nil}// New returns a logger that writes each record to tb.func ( TB) *slog.Logger {return slog.New(slog.NewTextHandler(&tbWriter{tb: }, nil))}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |