How do you capture logs and write them to `stderr`?

It’s possible to do the same, bot for stdio?

Do you know if something similar can be done for :stdio?