threaded_logger

Crates.iothreaded_logger
lib.rsthreaded_logger
version0.2.0
sourcesrc
created_at2021-05-25 08:08:10.146097
updated_at2021-05-27 08:39:14.418107
descriptionAn asynchronous logger wrapper
homepage
repositoryhttps://github.com/edwardycl/threaded_logger
max_upload_size
id401759
size6,877
Youngchan Lee (edwardycl)

documentation

README

threaded_logger

A logger wrapper that spawns tokio threads to make logging asynchronous.

Usage

It must be used with another logger crate that implements the log::Log trait. This crate only provides a wrapper function.

Also, a tokio runtime must be used.

Example

For example, you can use it with the env_logger crate.

Cargo.toml:

[dependencies]
log = "0.4.0"
env_logger = "0.8.3"
threaded_logger = "0.1.0"
tokio = { version = "1.0", features = ["full"] }

main.rs:

#[tokio::main]
async fn main() {
    let logger = env_logger::builder().build();
    let filter = logger.filter();

    threaded_logger::init(logger, filter);

    log::info!("hello");
}
Commit count: 7

cargo fmt