Rasant
Rasant is a lightweight, high performance and flexible Rust library for structured logging, inspired by the likes of zap and zerolog.
It offers nanosecond precision, stackable logging and outstanding performance: on modern systems, Rasant can process and dispatch logs to multiple sinks in tens of nanoseconds, being normally bottlenecked by I/O operations. Can't wait that long? There's built-in async support!


Main Features
- Minimal dependencies.
- Blazing fast performance, with zero allocations on most operations.
- Leveled, structured contextual logging with nanosecond precision.
- Simple API, with support for stacked logging.
- Configurable log filters.
- Thread safe.
- Highly configurable log sinks.
- Text and JSON log output.
- Support for dynamic async logging with constant lock time.
See also Why Rasant? for more background, and comparsions with other logging solutions for Rust.
Usage
Latest stable release is v0.7.0. To use it, add the rasant crate to your Cargo.toml file:
[]
= "0.7.0"
Rasant is under active development and on track for a v1.0.0 release. You may see small public API changes until then, but the library is otherwise stable and fully functional.
Getting Started
Basic Examples
Loggers can be easily initialized using sink defaults, and accessed via methods...
use rasant;
use Value;
let mut log = new;
log.add_sink.set_level;
log.set;
log.info;
log.warn_with;
log.debug;
...or the much nicer macro API:
use rasant as r;
let mut log = new;
log.add_sink.set_level;
set!;
info!;
warn!;
debug!;
2026-04-03 17:16:03.773 +0200 [INF] hello world! program_name="test"
2026-04-03 17:16:03.773 +0200 [WRN] here's some context program_name="test" line=7
Attributes
Rasant supports multiple attribute types: single scalars, lists and maps.
use rasant as r;
let mut log = new;
log.add_sink.set_level;
info!;
let simple_list = ;
info!;
info!;
info!;
2026-05-04 03:58:41.189 +0200 [INF] a single value=123.456
2026-05-04 03:58:41.189 +0200 [INF] lists can be simple list=[1, 2, 3, 4]
2026-05-04 03:58:41.189 +0200 [INF] or have mixed types list=["string!", 123.456, 0xc0a14]
2026-05-04 03:58:41.189 +0200 [INF] and so can maps! map={"key #1": 123, 456: 789.012}
Stacking
All loggers can be cheaply cloned, inheriting all settings from its parents - including
levels, sinks, filters and fixed attributes - allowing for very flexible setups. For example,
to have all errors (or higher) within a thread logged to stderr:
use rasant as r;
use thread;
let mut log = new;
log.add_sink.set_level;
info!;
let mut thread_log = log.clone;
spawn;
Configuring Sinks
Sinks can be configured to tweak multiple parameters, including time and overall output format.
use rasant as r;
let mut log = new;
log.set_level.add_sink;
info!;
{"time":"2026-04-03 16:03:04.481888522","level":"info","message":"hello!"}
Asynchronous Logging
All loggers can dynamically enable/disable async writes.
When in async mode, log operations have a slightly longer (as details are copied into a queue) but fixed lock time, making it ideal f.ex. for logging into slow storage without compromising overall performance.
use rasant as r;
let mut log = new;
log.set_level.add_sink;
info!;
log.set_async;
info!;
warn!;
info!;
Filtering
Rasant supports optional, configurable runtime filters for all log operations, including filtering by levels, log message, attribute key/value contents, and multiple sampling filters for statistical and monitoring purposes.
use rasant as r;
use Duration;
// Log a maximum of 10 Debug, Warning and Fatal updates per second, to keep SREs happy.
let mut log = new;
log
.add_sink
.set_all_levels
.add_filter
.add_filter;
info!;
debug!;
fatal!;
warn!;
Documentation
Support
Comments, feedback and bug reports are always welcome!
You can reach out through regular GitHub issues and bug reports, or via the rasant gitter channel.
Contributions will be accepted under the project's license.
To-Do's
Rasant is under active development, with more features planned for future versions.
- New output formants (hierarchical pretty print?)
- New sink types (f.ex. syslog)
- Support for third-party log sinks
- Binary output formats, such as CBOR and protobuf.
License
Rasant is distrubuted under the MIT license.