-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow indirect usage #1
Comments
The |
I see, but that still prints directly to stderr. In my case I want to control this myself for multiple reasons (eg writing some things to a file, maybe not having stderr available), and this does not allow that. Having for example a Display impl for a coloured panic formatter would be great there, since I could use it in every way possible, it'd be the most flexible. |
In other words: while plug-and-play is probably great for 90% of the use cases, it would be great if some other functionality would be available as public functions aswell (filtering the backtrace for example). |
To add to this, I'd love to be able to use this with backtraces produced by pub fn handle_script_result(ret: Result<(), Error>) {
let ret = match &ret {
Ok(_) => 0,
Err(e) => {
if backtrace.is_empty() {
info!("{}", "note: Run with `RUST_BACKTRACE=1` for a backtrace.");
} else {
info!("{:#?}", e.find_root_cause());
color_backtrace::print(e.backtrace());
};
error!("{}", e);
1
}
};
std::process::exit(ret);
} to just manage nicely printing the backtrace that I already have. If I try to replace this handler with an unwrap on the Result it KINDA works, but it prints the backtrace I care about as the message and produces a new backtrace that is nicely formatted where I unwrap the result. |
Exposing more of the currently internal API is certainly something we can do. The main reason for the current API to be extremely minimal is to give me some room for brutal refactorings without breakage while the crate is still very new. I'd suggest we wait a few weeks until most major issues surfaced, then we can take a look at exposing more stuff publicly! Supporting |
Imo breaking changes are not an issue, that's what semantic versioning is for, right 😃 |
Perhaps a trade-off at the expense of more maintenance burden: pull out the internals into a separate crate with the expectation of a lot of api churn and aggressive semantic version bumps there, and keep color-backtrace the minimal user-facing crate so that the internals, output printing, etc. can be changed across minor/patch updates? |
I now refactored things into a design that I'm happy with for now and exposed the printing functions as @yaahallo: in order to be able to use this with the failure crate, we'll have to ask them to expose access to the actual backtrace-rs I'll wrap these changes into a new release once we concluded on how to proceed with #2. |
Currently, the crate can only be used as the only, global, panic handler. It would be great if the formatter could be used separately, on a custom writer.
In my case, this prevents me from being able to use this, since I require some custom logic in my panic hook. It'd be awesome if I could make use of this beautiful formatting though!
The text was updated successfully, but these errors were encountered: