1 unstable release
Uses new Rust 2024
| 0.1.0 | Nov 14, 2025 |
|---|
#1085 in Debugging
81KB
1.5K
SLoC
ez_tracing
Tracing, made easy.
Do you want to structure debug information better than what dbg! gives you ?
Do you want to see what exactly happens in a multi-threaded program ?
Are you lost with the different crates that could solve these problem in a similar but not quite
the same way, in the Rust ecosystem ?
Then this crate is for you!
Overview
This crate provides a convinient way to setup logs and trace, using an easily configurable Tracer struct.
Features
-
verbosity-*: Compile time choice of the Console default verbosity level. If multiple are choosed, this will select the lowest verbosity level. IE:ErrorbeforeWarn. If none are chosen, this will default toWarn. -
bon: Use bon builders to create structs. This is a nicer interface than using raw strucs, but it increases compile time. -
chrono: Add the time as a prefix to the log files name. -
clap: Enable configuring the Console from the CLI, using the clap library.clap-log-file: Enable configuring the log files from the CLI.
-
serde: Enable creating Tracer and friends usings any Serde compatible de/serializer. This can be useful for configuration files. -
telemetry: Enables exporting traces to an OpenTelemetry compatible server.telemetry-auth: Connecting to an OpenTelemetry compatbile server that is protected by an authentication method.
-
tokio: Enable exporting traces to the Tokio console. You will need to addRUSTFLAGS="--cfg tokio_unstable"to your application during build time.
Examples
use ez_tracing::{errors::EErrorTracer, tracer::Tracer};
/// Log to `stdout` and `stderr` at the default `Warn` level
fn main() -> Result<(), EErrorTracer> {
let _guard = Tracer::default().try_setup_tracer()?;
# Ok(())
}
For a more thorough showcase, check out the tests folder, which also serves as examples.
Known issues
There is a known bug (#3309) in the tracing
crates that makes the instrument macro unreachable after a re-export.
To fix this, you can add, to your top lib.rs file:
use ez_tracing::tracing::*;
extern crate self as tracing;
License
Dependencies
~7–25MB
~241K SLoC