In CMSIS we are using a Test Framework that offers the flexibility to:
1. output to classic printf, but redirecting is on just a single place. 2. Record test output to memory (for devices that have not printf facility) 3. Output the test results in XML for nice formatting using browsers (we use this for filing test reports).
We have used this framework on various projects, across 4 different compilers, on many different targets (simulation, FPGA without UART, etc.).
The framework is for example here https://github.com/ARM-software/CMSIS-Driver_Validation/tree/master/Source. But we used it also for various other projects.
If there is interest, we could do some work to explain it better and make it scalable to TF-M.