debug icon indicating copy to clipboard operation
debug copied to clipboard

when %j exists in a formatted object, it pulls in the timestamp/delta

Open atuttle opened this issue 6 years ago • 4 comments

I found this when debugging some mysql search strings, so for example looking for a name like "jordan" to appear somewhere in a string, but wrapped with % to match anywhere in the string: %jordan%...

repro:

const demo = require('debug')('demo');
const data = [ '%j' ];
demo('%o', data);

Prints:

demo "\u001b[38;5;166m+30m\u001b[0m"

Note that the timestamp/delta is not appended to the end of the output as usual.

I know that %j is for pulling in json, but this is in the data object I'm running through the formatter. Is recursive formatting supposed to be happening? And even if it is, why would it pull in the timestamp/delta as if that were one of the arguments I was passing into the debug function?

atuttle avatar Feb 21 '19 16:02 atuttle

I've also seen %s trigger a similar effect, but when I tried to create a simple repro for the ticket it wouldn't happen on command for me. But here it is happening for an array containing %smith%...

image

atuttle avatar Feb 21 '19 20:02 atuttle

Is recursive formatting supposed to be happening?

Definitely not. Indeed a bug; good catch!

Qix- avatar Mar 11 '19 09:03 Qix-

2.6.8

RabiaSaid avatar Jun 21 '22 12:06 RabiaSaid

4.3.4

RabiaSaid avatar Jun 21 '22 12:06 RabiaSaid