HashMap
with valuable
is represented as a string in when using JSON formatter
#3039
-
Say I have code like this: fn my_function() {
let mut mymap: HashMap<String, String> = HashMap::new();
mymap.insert("hey".to_string(), "friend".to_string());
info!(mymap = tracing::field::valuable(&mymap), blah=2);
} I'm using The output looks like this: {
"timestamp": "2024-07-24T09:04:17.987349Z",
"level": "INFO",
"target": "aptos_api_gateway::http_proxy::http_handler",
"mymap": "{\"hey\": \"friend\"}",
"blah": 2
} I was hoping that the HashMap would be represented as JSON within the top level JSON, but as you can see, it's just a string representation. Is there any way to get the output to look like this? {
"timestamp": "2024-07-24T09:04:17.987349Z",
"level": "INFO",
"target": "aptos_api_gateway::http_proxy::http_handler",
"mymap": {
"hey": "friend"
},
"blah": 2
} I have tried this instead: #[derive(serde::Deserialize, serde::Serialize, valuable::Valuable)]
struct MyWrapper {
mymap: HashMap<String, String>,
}
...
info!(mywrapper = tracing::field::valuable(&MyHeaders::new(headers))); But I just get this:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Linking back to the Discord thread: https://discord.com/channels/500028886025895936/819261130861051986/1265600592693166177. |
Beta Was this translation helpful? Give feedback.
-
Are you using the unstable features and the |
Beta Was this translation helpful? Give feedback.
-
As @mladedav said, you are likely not enabling the unstable valuable feature on |
Beta Was this translation helpful? Give feedback.
-
Ah yes turns out that was it! I had the unstable feature enable but not the |
Beta Was this translation helpful? Give feedback.
As @mladedav said, you are likely not enabling the unstable valuable feature on
tracing-subscriber
.