1 // Copyright 2013-2014 The Rust Project Developers. 2 // Copyright 2018 The Uuid Project Developers. 3 // 4 // See the COPYRIGHT file at the top-level directory of this distribution. 5 // 6 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 7 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 8 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 9 // option. This file may not be copied, modified, or distributed 10 // except according to those terms. 11 12 use crate::Uuid; 13 14 impl slog::Value for Uuid { serialize( &self, _: &slog::Record<'_>, key: slog::Key, serializer: &mut dyn slog::Serializer, ) -> Result<(), slog::Error>15 fn serialize( 16 &self, 17 _: &slog::Record<'_>, 18 key: slog::Key, 19 serializer: &mut dyn slog::Serializer, 20 ) -> Result<(), slog::Error> { 21 serializer.emit_arguments(key, &format_args!("{}", self)) 22 } 23 } 24 25 #[cfg(test)] 26 mod tests { 27 use crate::tests::new; 28 29 use slog::{self, crit, Drain}; 30 31 #[test] test_slog_kv()32 fn test_slog_kv() { 33 let root = slog::Logger::root(slog::Discard.fuse(), slog::o!()); 34 let u1 = new(); 35 crit!(root, "test"; "u1" => u1); 36 } 37 } 38