k6
k6 copied to clipboard
`console.log`: Improve ArrayBuffer/TypedArray output formatting (Option 2)
Feature Description
Improve console.log output formatting for ArrayBuffer and TypedArray by modifying the traverseValue function to avoid json.Marshal entirely.
Suggested Solution (optional)
Following the discussion in #5469, two options were explored to achieve Deno-style output for ArrayBuffer and TypedArray:
- Option 1 (implemented in #5480): Uses
json.EncoderwithSetEscapeHTML(false). This prevents<>→\u003c\u003eescaping but retains extra quotes around formatted strings for nested objects.
{ "b": "ArrayBuffer { [Uint8Contents]: <00 00 00 00 00 00 00 00>, byteLength: 8 }", "v": "Int32Array(2) [ 4, 2 ]" }
- Option 2 (this issue): Modifies
traverseValueto avoidjson.Marshalentirely, achieving:- No HTML escaping (
<>stays as<>) - No extra quotes around formatted strings
- Output style:
{ key: value }for objects and[ elem, elem ]for arrays - Fully matches Deno-style output
- No HTML escaping (
{ b: ArrayBuffer { [Uint8Contents]: <00 00 00 00 00 00 00 00>, byteLength: 8 }, v: Int32Array(2) [ 4, 2 ] }
Already existing or connected issues / PRs (optional)
Original issue: #5469 Option 1 implementation: #5480
@inancgumus I have created this issue for Implementation of Option 2, followed it with a PR implementing the same. Thanks.
Closing as per @inancgumus - resolution going towards Option 2 in the main issue