forked from mirror/async-std
Merge #199
199: remove custom log code in favor of macro crate r=yoshuawuyts a=yoshuawuyts This removes our custom log macro code in favor of using [`kv-log-macro`](https://github.com/yoshuawuyts/kv-log-macro). This is a temporary crate that exists only until https://github.com/rust-lang-nursery/log/pull/353 lands which enables progress on https://github.com/rust-lang-nursery/log/issues/328. Thanks! Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>staging
commit
36c437bc09
@ -1,32 +0,0 @@
|
||||
use std::fmt::Arguments;
|
||||
|
||||
/// This struct only exists because kv logging isn't supported from the macros right now.
|
||||
pub(crate) struct LogData {
|
||||
pub parent_id: u64,
|
||||
pub child_id: u64,
|
||||
}
|
||||
|
||||
impl<'a> log::kv::Source for LogData {
|
||||
fn visit<'kvs>(
|
||||
&'kvs self,
|
||||
visitor: &mut dyn log::kv::Visitor<'kvs>,
|
||||
) -> Result<(), log::kv::Error> {
|
||||
visitor.visit_pair("parent_id".into(), self.parent_id.into())?;
|
||||
visitor.visit_pair("child_id".into(), self.child_id.into())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print(msg: Arguments<'_>, key_values: impl log::kv::Source) {
|
||||
log::logger().log(
|
||||
&log::Record::builder()
|
||||
.args(msg)
|
||||
.key_values(&key_values)
|
||||
.level(log::Level::Trace)
|
||||
.target(module_path!())
|
||||
.module_path(Some(module_path!()))
|
||||
.file(Some(file!()))
|
||||
.line(Some(line!()))
|
||||
.build(),
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue