yoshuawuyts/kv-log-macro

Not printing the key value pairs when using log4rs

Opened this issue · 0 comments

Bug Report

Your Environment

| Software | Version(s) |
| MacOS 11.04 |
| kv-log-macro 1.0.7 |
| Rustc - rustc 1.53.0-nightly (673d0db5e 2021-03-23 |

Expected Behavior

The last line of the example is:

info!("hello {}", "cats", {
            cat_1: "chashu",
            cat_2: "nori",
        });

I'm expecting this to print key of cat_1 and a value of cats etc.

{"message":"hello cats",level":"INFO", "cat_1": "chahu", ... }

Current Behavior

(removed irrelevant fields)

{"message":"hello cats",level":"INFO", ... }

Nothing related to the key value fields are logged at all.

Code Sample

The code:

use kv_log_macro::info;

#[tokio::main]
async fn main() {
    log4rs::init_file("./config/log4rs.yml", Default::default())
        .expect("Should have logging configuration at config/log4rs.yml");
    info!("hello {}", "cats", {
            cat_1: "chashu",
            cat_2: "nori",
        });
}

Log4rs config:

refresh_rate: 30 seconds

appenders:
  json_file:
    kind: file
    path: 'json.log'
    encoder:
      kind: json

  human_file:
    kind: file
    path: "human.log"
    encoder:
      pattern: "{h({d} {l} - {m}{n})}"

root:
  level: info
  appenders:
    - json_file
    - human_file