diff options
Diffstat (limited to 'examples/common')
-rw-r--r-- | examples/common/mod.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/common/mod.rs b/examples/common/mod.rs new file mode 100644 index 0000000..b83755d --- /dev/null +++ b/examples/common/mod.rs @@ -0,0 +1,36 @@ +use slog::*; +use std::{fmt, result}; + +pub struct PrintlnSerializer; + +impl Serializer for PrintlnSerializer { + fn emit_arguments(&mut self, key: Key, val: &fmt::Arguments) -> Result { + print!(", {}={}", key, val); + Ok(()) + } +} + +pub struct PrintlnDrain; + +impl Drain for PrintlnDrain { + type Ok = (); + type Err = (); + + fn log( + &self, + record: &Record, + values: &OwnedKVList, + ) -> result::Result<Self::Ok, Self::Err> { + + print!("{}", record.msg()); + + record + .kv() + .serialize(record, &mut PrintlnSerializer) + .unwrap(); + values.serialize(record, &mut PrintlnSerializer).unwrap(); + + println!(""); + Ok(()) + } +} |