Crates.io | parallel_logger |
lib.rs | parallel_logger |
version | 0.4.0 |
source | src |
created_at | 2024-02-16 15:07:23.682162 |
updated_at | 2024-02-26 14:30:13.470771 |
description | A logger implementing the log::Log trait that allows other loggers to run in a separate thread, reducing load on the calling thread significantly |
homepage | |
repository | https://github.com/8192K/parallel_logger |
max_upload_size | |
id | 1142524 |
size | 27,621 |
A simple logger that does not do logging by itself but passes all log events to an arbitrary number of actual loggers running in parallel. Depending on the parallel execution mode, the actual loggers are executed either in sequence (ParallelMode::Sequential
) on one thread or in parallel (ParallelMode::Parallel
) using one thread per actual logger. ParallelMode::Sequential
should be sufficient for most use cases.
Very useful when logging is a bottleneck such as in realtime scenarios and/or when logging to a network or database etc.
Add the dependency to your Cargo.toml
:
[dependencies]
log = "0.4"
parallel_logger = "0.3"
How to use in your application:
use parallel_logger::{ParallelLogger, ParallelMode};
fn main() {
ParallelLogger::init(log::LevelFilter::Info, ParallelMode::Sequential, vec![any_logger_1, any_logger_2, ...]>);
}
Make sure not to create other loggers by using their respective init
methods, but to use their new
methods instead.
Do not register any other logger with the log crate before as the ParallelLogger will take that place.
Licensed under either of