everything_plugin/
log.rs

1#[cfg(feature = "tracing")]
2pub use tracing::{debug, error, info, trace, warn};
3
4/// A convenient function to initialize [`tracing`] with a default configuration.
5#[cfg(feature = "tracing")]
6pub fn tracing_init() {
7    #[cfg(not(feature = "tracing-appender"))]
8    let stderr = anstream::stderr;
9    #[cfg(feature = "tracing-appender")]
10    let stderr = {
11        let (non_blocking, guard) = tracing_appender::non_blocking(anstream::stderr());
12        std::mem::forget(guard);
13        non_blocking
14    };
15
16    tracing_subscriber::fmt()
17        .with_writer(stderr)
18        .with_max_level(tracing::Level::DEBUG)
19        .init();
20
21    #[cfg(debug_assertions)]
22    std::panic::set_hook(Box::new(|info| {
23        tracing_panic::panic_hook(info);
24        std::thread::sleep(std::time::Duration::from_secs(60));
25    }));
26}