In Rust, how do I take the inputs "Some string" and {"Message":"Some string"} and turn them both into the JSON: {"Message": "Some string", "Source": "My app"}? I've tried doing this via the following macro, but it doesn't work.
macro_rules! my_logger {
($level:literal, $msg:tt) => {
let mut jsonval = json!($msg);
if let Map(m) = $msg {
m.insert("app", "foobar");
} else {
let m = Map::new();
m.insert("app", "foobar");
jsonval = m;
}
println!("{}: {}", $level, jsonval.to_string());
}
}
I'm trying to log my application data using JSON. I'd use tracing, but I need the logging macros my vendor provides to connect to the logging vendor (New Relic) and I don't know how do make tracing do that. :)