A minimal, zero-heap Rust logging library for CLI applications.
Add to your Cargo.toml:
[dependencies]
loglet = "0.0.2"Or via the command line:
cargo add loglet- Zero heap allocations (uses
fmt::Argumentsthroughout) - Coloured output via
owo-colors - Tagged log entries
- Custom log levels
- Debug logs compiled away in release builds
- Writes errors to
stderr, everything else tostdout
From examples/basic_usage.rs:
use loglet::{info, warn, error, debug};
fn main() {
info!("Starting application.");
let user = "Alice";
let attempts = 3;
warn!("Failed login by '{}' (attempt #{})", user, attempts);
error!("Database connection timed out!");
debug!("Hidden in release builds.");
// Tagged
info!(tag: "auth", "User '{}' logged in.", user);
warn!(tag: "db", "Connection pool running low.");
error!(tag: "network", "Host unreachable after {} retries.", 5);
}Check out the examples/ folder for more.
| Macro | Prefix | Stream | Color |
|---|---|---|---|
info! |
I |
stdout | Green |
warn! |
W |
stdout | Yellow |
error! |
E |
stderr | Red |
debug! |
D |
stdout | Cyan |
Custom levels are also supported (see examples/custom_level.rs)
Clone the repo first:
git clone https://github.com/AltIsBacc/loglet
cd logletThen run any example:
cargo run --example basic_usage
cargo run --example custom_levelMIT