mirror of
https://github.com/eyre-rs/eyre.git
synced 2025-12-15 20:47:34 +00:00
* port color-eyre to new eyre with global hook * add a singular hook configuration * add panic handler to globally installed hook * getting near the end * remove unused module * temp: working on capture consistency * walk back changes that make porting to new release harder * merge main into hooked * switch to github color-spantrace and copy from htmlgit status * move spantrace capture default mode into hook * rename and reorg section stuff * switch to released deps * copy changes from lib.rs to readme * update snippets and revert to images for readme * remove extremely fragile format tests
34 lines
771 B
Rust
34 lines
771 B
Rust
use tracing::instrument;
|
|
|
|
#[instrument]
|
|
fn main() {
|
|
#[cfg(feature = "capture-spantrace")]
|
|
install_tracing();
|
|
color_eyre::install().unwrap();
|
|
|
|
do_thing(42);
|
|
}
|
|
|
|
#[instrument]
|
|
fn do_thing(thing: u32) {
|
|
panic!("some real basic stuff went wrong")
|
|
}
|
|
|
|
#[cfg(feature = "capture-spantrace")]
|
|
fn install_tracing() {
|
|
use tracing_error::ErrorLayer;
|
|
use tracing_subscriber::prelude::*;
|
|
use tracing_subscriber::{fmt, EnvFilter};
|
|
|
|
let fmt_layer = fmt::layer().with_target(false);
|
|
let filter_layer = EnvFilter::try_from_default_env()
|
|
.or_else(|_| EnvFilter::try_new("info"))
|
|
.unwrap();
|
|
|
|
tracing_subscriber::registry()
|
|
.with(filter_layer)
|
|
.with(fmt_layer)
|
|
.with(ErrorLayer::default())
|
|
.init();
|
|
}
|