ltrait/
lib.rs

1pub use async_trait;
2pub use color_eyre;
3pub use tokio_stream;
4
5pub use tracing::Level;
6use tracing_log::LogTracer;
7use tracing_subscriber::fmt::format::FmtSpan;
8
9pub mod action;
10pub mod filter;
11pub mod generator;
12pub mod launcher;
13pub mod sorter;
14pub mod source;
15pub mod ui;
16
17pub use crate::action::Action;
18pub use crate::filter::Filter;
19pub use crate::launcher::Launcher;
20pub use crate::sorter::Sorter;
21
22use color_eyre::eyre::Result;
23
24fn init_subscriber_with_level(level: Level) {
25    tracing_subscriber::fmt()
26        .with_max_level(level) // set recorded log level
27        .with_span_events(FmtSpan::ACTIVE) // enable record span timing
28        .init();
29}
30
31/// Install color_eyre and setup tracing(with tracing-log)
32/// ```
33/// use ltrait::{Level, setup};
34///
35/// let _ = setup(Level::TRACE);
36/// ```
37pub fn setup(log_level: Level) -> Result<()> {
38    color_eyre::install()?;
39
40    init_subscriber_with_level(log_level);
41    LogTracer::init()?;
42
43    Ok(())
44}