I'm not sure I completely grasp the use case here in detail, but FWIW, I explored collation of log lines per-test with
https://pkg.go.dev/golang.org/x/exp/slog a while ago and ended up with a struct that implements both testing.TB and slog.Handler. The idea was:
(1) testing.TB methods that log, write to a buffer (Error/f, Fatal/f, Log/f, Skip/f) - the calls can be made into slog records, even
(2) slog.Handler methods write to the same buffer - so, the instance can just be passed to some code under test that slogs
(3) the buffer dumps to test output when a test failure with Error/f or Fatal/f is seen
If the goal is getting a nice sequence of just the relevant log lines leading to a test failure, this is feasible for independently executing tests.
If there is crosstalk between parallel tests, this isn't sufficient - structured logging maybe makes the problem easier but it's not trivial.