Crates.io | ring-log |
lib.rs | ring-log |
version | 0.1.1 |
source | src |
created_at | 2024-09-07 21:58:00.15856 |
updated_at | 2024-09-23 11:44:20.730948 |
description | High-performance logger with lock-free ring buffer |
homepage | |
repository | https://github.com/freergit/ring-log.git |
max_upload_size | |
id | 1367606 |
size | 12,983 |
High-performance logger with lock-free ring buffer, use this library when you want to log in the hotpath and performance is critical.
Submitting a log to either stdout or a file is very simple, you just give a closure which evaluates to a string. This is extremely fast, usually less than 100 nanos. A simple example:
let o = LoggerFileOptions {
path: "log.txt",
append_mode: false, // should the logger just append to what's already there or overwrite?
};
// The size is bounded, issuing a new log when the ringbuffer is full will block.
let logger = Logger::new(1024 * 8, Some(o));
// Log to stdout
logger.log(|| format!("To stdout: {}", 42));
// Log to the file, format_log! will prepend the file and LOC location to the log.
logger.log_f(|| format_log!("To log.txt {}", 5)); // path/to/file:LINE: To log.txt 5
// Blocks until all logs are handled.
logger.shutdown();