Function print_to

Source
fn print_to<T>(args: Arguments<'_>, global_s: fn() -> T, label: &str)
where T: Write,
Expand description

Writes args to the capture buffer if enabled and possible, or global_s otherwise. label identifies the stream in a panic message.

This function is used to print error messages, so it takes extra care to avoid causing a panic when OUTPUT_CAPTURE is unusable. For instance, if the TLS key for output capturing is already destroyed, or if the local stream is in use by another thread, it will just fall back to the global stream.

However, if the actual I/O causes an error, this function does panic.

Writing to non-blocking stdout/stderr can cause an error, which will lead this function to panic.