% symbol in object interpreted as formatter
const debug = require('debug')('foo') debug.enabled = true // Or use ENV variables const someObjectIWantToLog = { "%j": "%j %j %%" } debug("%o", someObjectIWantToLog, 1, 2, 3)
result:
foo { '1': '2 3 %' } +0ms
expected result:
foo { "%j": "%j %j %%" } 1 2 3 +0ms
This gets even weirder when running the following several times:
debug("%o", { "%j": "%j %j %%" }) debug("%o", { "%j": "%j %j %%" }) debug("%o", { "%j": "%j %j %%" }) debug("%o", { "%j": "%j %j %%" })
result:
foo { '"\u001b[38;5;148m+3s\u001b[0m"': '%j %j %' }
foo { '"\u001b[38;5;148m+847ms\u001b[0m"': '%j %j %' }
foo { '"\u001b[38;5;148m+674ms\u001b[0m"': '%j %j %' }
foo { '"\u001b[38;5;148m+620ms\u001b[0m"': '%j %j %' }
Did I miss something in the doc? Is there a way not to interpret those % symbols? Or is this a bug?