On Fuchsia, most of our processes run in an environment where STDOUT and STDERR are redirected to an equivalent to /dev/null. Instead, we structure most of our components to emit logs to a central syslog service, which allows us to attach more structured data to each message. Overall this works well for us, except in the case of our main functions returning Result::Err. By default, the
Termination trait just logs the error with
eprintln!(), and so these messages get lost. Presumably other operating system services could run into this, such as if a linux service running under systemd is set to run with:
... StdoutOutput=null StderrOutput=null ...
Has anyone explored creating an equivalent to
std::panic::set_hook for the
Termination trait? It seems like it'd be a pretty easy RFC and feature to write up, especially since we have a precedent with
set_hook. I'd be happy to start working on this, but I wanted to check here first if there has been prior art in this space. I couldn't find anything on GitHub - rust-lang/rfcs: RFCs for changes to Rust or here.