> Associate with the context a Logger that goes to T.Log?

That is indeed the approach taken in 
https://pkg.go.dev/k8s.io/klog/v2/ktesting for contextual logging with 
go-logr.

https://pkg.go.dev/golang.org/x/exp/slog doesn't have anything for it at 
the moment, at least not out-of-the-box.

The problem is that every single test needs to be modified for it to work. 
I was hoping to avoid that for `t.Error`, but given the reactions so far, 
that's probably what we'll have to do. Perhaps I'll write a code generator 
which wraps `KTestFoo([ctx *context.Context, ]t testing.TB)` in a generated 
`TestFoo(t *testing.T)`.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/c857b78b-f2bc-47c5-96ed-0cd68693a6cfn%40googlegroups.com.

Reply via email to