Skip to content

Instantly share code, notes, and snippets.

@caipre caipre/slog-expression.rs
Last active Oct 25, 2016

Embed
What would you like to do?
#[macro_use]
extern crate slog;
extern crate slog_term;
use slog::DrainExt;
#[derive(Debug)]
enum Topic {
First,
Second,
Third,
}
macro_rules! debugify
{ ($v:path) => (format!("{:?}", $v)) }
fn main() {
let drain = slog_term::streamer().compact().build().fuse();
let log = slog::Logger::root(drain, o!("version" => "0.5"));
warn!(log, "topic" => debugify!(Topic::First); "message");
warn!(log, "message"; "topic" => debugify!(Topic::First));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.