Replies: 2 comments 2 replies
-
Do you want to output escaped JSON for the If you wanted to output a JSON object in the |
Beta Was this translation helpful? Give feedback.
-
The message could be anything - string, integer, pointers, or a json blob/object. We would like to see all messages enclosed by dquotes so I have to go with Note: Neither LOG_INFO(json.dump()) nor LOG_INFO("{}", json.dump()) escape the message |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I set up my formatter with a custom pattern
My flag "j" adds a certain uid that has relevance to my code
While calling the log, I use nlohmann::json to generate a json
The output json is invalid in the "message" field:
{"@timestamp":"2023-12-27T15:46:41.636829Z","message":"{"k1":"v1","k2":2}","level":"error","uid":25,"source":"main.cpp","function":"testPost","line":"23"}
It would work if the string supplied to message were escaped but nlohmann::json doesn't have that capability because
.dump()
prints the object per json spec. Any suggestions on what can be done here? Should I write a custom print for my json obj that returns the json as a string that has the key-value pairs without dquotes?Beta Was this translation helpful? Give feedback.
All reactions