I’m trying to get to a pino like logger output.
the problem is that any setup I got results with stringifying the metadata into the message instead of embedding it into the log entry record.
Has anybody tried that before?
I’m getting convinced that if I do that I’ll have to create an extension for that, at least one that will write to stdout without the “envelope” that come with console.log…
Another direction I considered is a pipe-transformer/beautifier like pino-pretty that I can pipe the stdout of k6 into it will transform it - but if I --log-output json - I get it on stderr.
if I 2>&1 then I get everything together, including the banners and summary which I seem to miss how to configure - its always print in text, even if I --out json --log-output json.
…
I hope there’s some undocumented config that im missing… this could be great.
Any point in the rihgt direction will be appreciated
I’m sorry, but I think what you’re looking for, unless I misunderstood something, is not feasible, as k6 is quite flexible to configure different formats and destinations (it even allows you to send logs to a Loki endpoint), but isn’t flexible enough to achieve what you’re trying to.
However, as you suggested, you can always build your own extension. After a quick search, I’ve found this extension which is used to use the zap library for logging. But note that, in this case, it also requires changing the way the script is written, to stop relying on standard console.log et al.
Other than that, I can only think about other tools that manipulates/transform the k6’s output from outside, as you also suggested, but I’m not aware of any specific explanation of how to do so.
That said, and for the sake of looking whether somebody else can help you with that, could you please share an example of what you get now with available k6 options, and an example of how you would like the output/logs to look like, please?