Skip to content

kv::value::Value constructed from String uses Debug output for Display #395

@yoshuawuyts

Description

@yoshuawuyts

@isgj reported an issue in Tide http-rs/tide#495 (comment) that led us to file in issue in Femme lrlna/femme#12 about output that was being printed with extra quotes:

{"level":30,"time":1589717147052,"msg":"Response sent","method":"\"GET\"","status":"200","duration":"\"157ms\"","path":"\"/api/v1/users\""}

The printing logic in femme looks like this:

    impl<'kvs, 'a> kv::Visitor<'kvs> for Visitor<'a> {
        fn visit_pair(
            &mut self,
            key: kv::Key<'kvs>,
            val: kv::Value<'kvs>,
        ) -> Result<(), kv::Error> {
            write!(self.string, "\n    {} {}", style(key).bold(), val).unwrap();
            Ok(())
        }

It turns out that the problem stems from the Display path using the Debug logic: https://docs.rs/log/0.4.8/src/log/kv/value/internal.rs.html#111-117. Currently in master this code seems refactored, but still inherently the same: https://github.com/rust-lang/log/blob/master/src/kv/value/internal/mod.rs#L49-L51.

We should probably introduce a new Display path for values so that they can correctly be displayed. Thanks!

cc/ @KodrAus

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions