eyre-rs / color-eyre

Custom hooks for colorful human oriented error reports via panics and the eyre crate
Other
960 stars 57 forks source link

Make the usage of tracing spans more visible #82

Open ghost opened 3 years ago

ghost commented 3 years ago

From examples/theme_test_helper.rs:

//! Nothing interesting here. This is just a small helper used in a test.

I beg to differ 😄

Using color-eyre along with the span+guard pattern:

let span = tracing::info_span!("my_span", msg);
let _guard = span.enter();

For me gives the best error reporting I have found as of yet in Rust. (I wish it was a bit more ergonomic to set up though).

I realize this might fall into the domain of tracing more than color-eyre (?), but I think it's so useful an example highlighting it would be very welcome.