Open dgrnbrg opened 7 years ago
Hum, interesting idea! It should just be optional so that people who don't need it don't pay for it.
We should take into account that all errors don't have the same impact, so maybe it should be configurable?
Here's what I think makes sense:
quick_main!
uses error!
instead of println!
when the feature's enabledchain_err
prints the return value of its closure using debug!("{:?}", err)
if it ends up actually chaining an error, and if the return value of the closure implements Debug
(I think this is doable via Any
for a runtime check whether it supports Debug
).Logging potentially caught errors to debug
should mostly be useful for situations in which errors are being used, but logging hasn't been written. As a result, I think using any level more urgent than debug
or trace
isn't desirable, as this feature would make it easier to get a bit more debugging context without recompiling; it wouldn't replace proper logging.
Hello, I've created a pull request finally to solve this. I gave up for a while without realizing that #[cfg()]
attributes are silently ignored or have different behavior on expressions within macros than on top level functions.
My application uses the general Rust
log
crate, as well as lots oferror_chain
. I'd like to contribute a feature for this crate calledlog
, which causesquick_main!
to write its output toerror!
instead of (or in addition to)stderr
when the feature is enabled.Additionally, I think it could be useful to have calls to
chain_err
write their information at thedebug
level; however, this could be overly verbose. At the same time,chain_err
closures contain a lot of useful information that could reduce the burden to write useful logging statements, but still be able to debug an application more easily.Would you be willing to accept this contribution?