2 unstable releases

0.1.0 Mar 13, 2020
0.0.1 Mar 12, 2020

#19 in #structured

Download history 9/week @ 2021-09-25 27/week @ 2021-10-02 12/week @ 2021-10-09 18/week @ 2021-10-16 16/week @ 2021-10-23 14/week @ 2021-10-30 12/week @ 2021-11-06 7/week @ 2021-11-13 13/week @ 2021-11-20 43/week @ 2021-11-27 13/week @ 2021-12-04 13/week @ 2021-12-11 7/week @ 2021-12-18 24/week @ 2021-12-25 38/week @ 2022-01-01 27/week @ 2022-01-08

98 downloads per month

MIT/Apache

13KB
265 lines

logfmt formatter for slog

This is a pretty straightforward logfmt formatter with a customizable prefix. The formatter exposed by the crate is not Send or Sync, so you'll have to wrap it in slog-async or similar.


lib.rs:

slog_logfmt - a logfmt formatter for slog.

This crate exposes a slog drain that formats messages as logfmt.

Example

use slog_logfmt::Logfmt;
use slog::{debug, o, Drain, Logger};
use std::io::stdout;

let drain = Logfmt::new(stdout()).build().fuse();
let drain = slog_async::Async::new(drain).build().fuse();
let logger = Logger::root(drain, o!("logger" => "tests"));
debug!(logger, #"tag", "hi there"; "foo" => "bar'baz\"");

Writes:

DEBG | #tag	hi there	logger="tests" foo="bar\'baz\""

Dependencies

~140KB