We are, I hope, nearing completion of the RFC for a println!-alike that writes to stderr. (In an utterly textbook case of the bikeshed effect, there is consensus that the macro should be added, but we are still arguing over what it should be called.
) In the process, a library wart came up, and I thought I’d split it off and bring it up here.
println! writes to io::stdout - or does it? There is an undocumented, unstable hook, set_print, that redirects println! to an arbitrary io::Write instance. But it only affects println!; other uses of io::stdout are unaffected. And it only affects the thread on which it is called. Similarly, there is a set_panic hook that redirects the output of panic!, assert!, etc, but only for the current thread, and does not affect io::stderr. (As currently planned, it will affect the new println!-alike.)
The question for discussion is: should set_print and set_panic affect io::stdout and io::stderr, and if they do, should it be in a thread-local or process-global fashion?
I do not know what existing users of these functions expect. There is only one use of set_print in the rust core tree, in librustdoc, and frankly I don’t understand what it’s trying to do. There are more uses of set_panic, but they are in conjunction with using the compiler as a library, and I don’t understand the semantics of that.