kodraus feedback

Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
Yoshua Wuyts 2019-09-02 01:26:00 +02:00
parent b99c0fb53a
commit 0a157f19ee
No known key found for this signature in database
GPG Key ID: 24EA8164F96777ED
2 changed files with 2 additions and 26 deletions

View File

@ -1416,32 +1416,8 @@ pub fn __private_api_log(
args: fmt::Arguments<'_>,
level: Level,
&(target, module_path, file, line): &(&str, &'static str, &'static str, u32),
kvs: Option<&[(&str, &str)]>,
kvs: Option<&[(&str, &kv::ToValue)]>,
) {
// Ideally there would be a `From` impl available for this.
struct KeyValues<'a> {
inner: &'a [(&'a str, &'a str)],
}
impl<'a> kv::Source for KeyValues<'a> {
fn visit<'kvs>(&'kvs self, visitor: &mut kv::Visitor<'kvs>) -> Result<(), kv::Error> {
for pair in self.inner {
visitor.visit_pair(pair.0.into(), pair.1.into())?;
}
Ok(())
}
#[inline]
fn count(&self) -> usize {
self.inner.len()
}
}
let kvs = match kvs {
Some(kvs) => Some(KeyValues { inner: kvs }),
None => None,
};
logger().log(
&Record::builder()
.args(args)

View File

@ -67,7 +67,7 @@ macro_rules! log_impl {
__log_format_args!($($arg),*),
lvl,
&(__log_module_path!(), __log_module_path!(), __log_file!(), __log_line!()),
Some(&[$((__log_stringify!($key), $value)),*])
Some(&[$((__log_stringify!($key), &$value)),*])
);
}
};