llrt
llrt copied to clipboard
Unable to log in JSON structured format
Hi, I am trying to follow: JSON logging option in the console
But the following code: console.log({ data: 12.3, flag: false });
Produces a single string instead of key-value pairs:
{
"time": "2024-03-01T19:55:28.045Z",
"requestId": "bf340645-6ed9-40a3-ae15-2a82dc83ec5d",
"level": "INFO",
"message": "{ data: 12.3, flag: false }"
}
Hi @nocquidant! Thanks for the report. There seems to be a bit of inconsistent behavior with how Node.js outputs JSON log format in Lambda. I see now that if only 1 argument was passed to console.log it gets expanded and converted into json, if multiple are added, it's consistent with LLRT. I'm raising this with the service team.
Question: Ignoring how it works today, what would in your opinion be the best output for something like this?
console.log({ data: 12.3, flag: false },"example",{obj2: 1});
Fixed by: https://github.com/awslabs/llrt/pull/264