also add source to Test logger

This commit is contained in:
miampf 2024-01-31 16:17:36 +01:00
parent e435211a70
commit b0bbea80f1
No known key found for this signature in database
GPG Key ID: 376EAC0E5307A669

View File

@ -107,7 +107,7 @@ func NewJSONLogger(level slog.Level) *slog.Logger {
// NewTest creates a new slog.Logger that writes to a testing.T.
func NewTest(t *testing.T) *slog.Logger {
return slog.New(slog.NewTextHandler(testWriter{t: t}, nil))
return slog.New(slog.NewTextHandler(testWriter{t: t}, &slog.HandlerOptions{AddSource: true}))
}
// TestWriter is a writer to a testing.T used in tests for logging with slog.