debug icon indicating copy to clipboard operation
debug copied to clipboard

Using debug with `esm` renders wrong formatted output for %o / %O

Open dbo opened this issue 5 years ago • 2 comments

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

dbo avatar Jan 29 '20 15:01 dbo

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).

Konakona-chan avatar Oct 14 '21 15:10 Konakona-chan

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.

Qix- avatar Oct 14 '21 15:10 Qix-