Open dgrnbrg opened 7 years ago
Hum, not sure it's needed... It's a 5 lines function, it's easy to copy if you want more customization.
I think that this is really valuable for continuing to mature rust. The quick_main!
macro is used all over, because it's essentially an adapter that lets you write natively error-chaining libs with the boilerplate generated for you.
For users like me, our systems make extensive use of logging & error-chain. What this really does is makes it easy to write quick CLI tools and take advantage of error-chain & the logging already supported in the application.
The motivation here is that often, one needs to run applications unattended, and this allows boilerplate-free programs to have the reason they terminated in their log file. So, to me, the reason this is valuable is that it handles the 99% case of users who are using the standard log
crate, since the termination reason shows up in the log file, plus it keeps the boilerplate down to zero.
Sorry for the delay. Could you update the files?
@Yamakaky what do you think about adding a set of functions to log erros (using the log crate) that are added to the ResultExt trait? The functions would be:
loge()
: prints the error and the cause chain using error!
logw()
: same with warn!
logi()
: same with info!
logd()
: same with debug!
?
It is often that I want to log some errors as they happen without adding a lot of boilerplate if/match and calls to display_error. The functions would be used like chain_err(..)
whenever the user wants to log that error at the spot.
something like:
fun_returning_result().chain_err(|| MyCustomErr("some info')).loge()?
quickmain_log
When
quickmain_log
is enabled, thequick_main!
entry point writes the terminating error chain tolog::error!
instead of stdout.Solves #165.