Skip to content

Instantly share code, notes, and snippets.

@caipre
Last active October 25, 2016 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caipre/a63f739a87e7929db3a41280322ade2f to your computer and use it in GitHub Desktop.
Save caipre/a63f739a87e7929db3a41280322ade2f to your computer and use it in GitHub Desktop.
#[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