probably_fine_log
A fast, zero-dependency error logger for Rust — works on every platform including embedded targets.
Features
| Feature | Detail |
|---|---|
| Zero dependencies | Only the Rust standard library |
| Lock-free filtering | AtomicUsize max-level check — filtered calls cost ~1 ns |
| Thread-safe | Global logger installed with OnceLock; no mutex on the hot path |
| Structured records | File, line, module path, and millisecond timestamp on every record |
| Pluggable | Implement the Logger trait to write to files, ring buffers, sockets, … |
| All platforms | Linux, macOS, Windows, WASM, embedded (no_std with default-features = false) |
Quick start
# Cargo.toml
[]
= "0.1"
use ;
use ;
Output (with colour):
2024-01-15T12:34:56.012Z [INFO ] my_app Listening on port 8080 (src/main.rs:9)
2024-01-15T12:34:56.013Z [DEBUG] my_app Connection pool size: 16 (src/main.rs:10)
2024-01-15T12:34:56.014Z [WARN ] my_app Retry 2/3 (src/main.rs:11)
2024-01-15T12:34:56.015Z [ERROR] my_app Fatal: disk full (src/main.rs:12)
Custom logger
use ;
;
Level filtering
Filtering is a single relaxed atomic load — below the noise floor of any I/O:
set_max_level; // only Error + Warn pass through
Log levels
| Macro | Level | Numeric |
|---|---|---|
error! |
Level::Error |
1 |
warn! |
Level::Warn |
2 |
info! |
Level::Info |
3 |
debug! |
Level::Debug |
4 |
trace! |
Level::Trace |
5 |
Records with a numeric value greater than the current max are dropped before the logger is called.
no_std support
Disable the default std feature to compile on bare-metal targets:
[]
= { = "0.1", = false }
In no_std mode the macros and NullLogger are available; StderrLogger, timestamp formatting, and set_logger require std.
License
MIT