#slog #json #logging

slog-json-concur

JSON drain for slog-rs with concurrency

1 unstable release

0.1.0 Jul 17, 2022

#833 in Concurrency

MPL-2.0 OR MIT OR Apache-2.0

17KB
257 lines

slog-json-concur

Crate version Docs

A simple fork of the slog-json 2.6.1 (original version by Dawid Ciężarkiewicz) crate which introduces a buffering and concurrency while generating output of a log record.

An original drain requires mutex before using. This fork introduces a buffering before final write and it uses a mutex only on same final write, making same logging as concurrent and parallel.

Original slog-json: https://crates.io/crates/slog-json, https://github.com/slog-rs/json.


lib.rs:

JSON Drain for slog-rs - with concurrency

#[macro_use]
extern crate slog;

use slog::Drain;

fn main() {
    let root = slog::Logger::root(
        slog_json_concur::Json::default(std::io::stderr()).map(slog::Fuse),
        o!("version" => env!("CARGO_PKG_VERSION"))
    );
}

Dependencies

~1.2–1.7MB
~34K SLoC