tiny-tracing
A lightweight, builder-style logging library for Rust that wraps tracing and
tracing-subscriber. Designed for small to medium projects that want structured or
plain-text output with zero fuss.
Quickstart
Add the crate to your project:
cargo add tiny-tracing
Minimal setup — text output at INFO level, nothing else needed:
use Logger;
Configuration
The builder API exposes every knob through chainable methods:
use ;
| Method | Default | Description |
|---|---|---|
with_level(Level::DEBUG) |
Level::INFO |
Static log level (tracing::Level) |
with_format(LogFormat::Json) |
LogFormat::Text |
Output format |
with_env_filter("info,my_crate=debug") |
none | Per-target filter via EnvFilter |
with_file(true) |
false |
Show source file path in log lines |
with_target(false) |
true |
Show module path in log lines |
Need to load config from a string (env var, TOML)? LogFormat implements FromStr,
and tracing::Level does too:
use ;
let format: LogFormat = "json".parse?;
let level: Level = "debug".parse?;
# Ok::
Examples
Runnable examples live under examples/:
Safety
The library calls tracing_subscriber::try_init() internally — calling init() more
than once returns a LoggerError::TryInitError instead of panicking. No unsafe code
anywhere in the crate.
License
tiny-tracing is distributed under the terms of the MIT license.
Development
Releases are automated via cocogitto (Conventional Commits). See the release skill for the full workflow.