debug
debug copied to clipboard
Using debug with `esm` renders wrong formatted output for %o / %O
Using debug with or without esm produces different formatted output using %o or %O:
$ DEBUG=topic node -r esm -p 'require("debug")("topic")("out: %o", { foo: "?date=2020-01-29T14%3A24%3A44.806Z" })'
topic out: { foo: '?date=2020-01-29T14undefinedA24undefinedA44.806Z' } +0ms
undefined
whereas the following correctly renders
$ DEBUG=topic node -p 'require("debug")("topic")("out: %o", { foo: "?date=2020-01-29T14%3A24%3A44.806Z" })'
topic out: { foo: '?date=2020-01-29T14%3A24%3A44.806Z' } +0ms
undefined
Related to #786. ESM is known for working with imports as with immutable objects (so that adjacent js file can not inject %o formatter as simple, as it was in CSM).
Not sure what the issue is here, and I don't know why esm would have anything to do with this.
For some reason, it appears the logger is treating the % in the date string as a formatting delimiter and trying to pull them from subsequent arguments. It's quite strange and certainly not right.
I'm hoping the v5 release will fix this.