mirror of
https://gitee.com/openharmony/third_party_rust_log
synced 2024-11-27 01:40:27 +00:00
kodraus feedback
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
parent
b99c0fb53a
commit
0a157f19ee
26
src/lib.rs
26
src/lib.rs
@ -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)
|
||||
|
@ -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)),*])
|
||||
);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user