Crates.io | low_latency_log |
lib.rs | low_latency_log |
version | 0.2.0 |
source | src |
created_at | 2024-06-20 09:01:15.0244 |
updated_at | 2024-06-20 09:30:52.753836 |
description | Fast and Low Latency Logging Library for Rust |
homepage | |
repository | https://github.com/WANG-lp/low-latency-log |
max_upload_size | |
id | 1277758 |
size | 50,551 |
low-latency-log
is a high-performance and low-latency Rust logging library.
low-latency-log
is designed with performance in mind, utilizing techniques such as minimizing the size of critical data structures, avoiding locks on critical paths, and caching formatted strings.low-latency-log
offloads all heavy logging operations (such as formatting, time conversion, etc.) to independent threads, ensuring the calling thread is not blocked.low-latency-log
offers comparable p999 latency to quill
and leads in throughput among quill
, spdlog-rs
, ftlog
, and fast_log
.
For more details, please refer to the Benchmark.
To build the benchmark binaries, run:
cargo b -r -p bench
use low_latency_log::{info, Level};
use std::fs;
fn main() {
let rc = RollingCondition::new().daily();
// Remember to keep the following guard, otherwise the global logger stops immediately when the guard auto-drops
let _guard = low_latency_log::Logger::new(rc, "/dev/shm".to_string(), "log.log".to_string())
.cpu(1)
.init()
.unwrap();
for i in 1..1_000_001 {
info!("number {}", i);
}
// _guard auto-dropped and log flushed
}
The following optimizations are in progress:
format!
.ufmt
to provide more types of formatting support (e.g., floating-point types).low_latency_log
outputs fixed time and log formats.log
crate.low_latency_log
is heavily inspired by the following projectsThis project is licensed under the Apache License.
Some code comes from the logflume
project. Please refer to LICENSE-LOGFLUME for more information.