2 unstable releases

0.1.0 Mar 13, 2020
0.0.1 Mar 12, 2020

#823 in Debugging

Download history 6/week @ 2024-04-22 1/week @ 2024-05-13 10/week @ 2024-05-27 1/week @ 2024-06-10

92 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

~160KB