Skip to content

% symbol in object interpreted as formatter #766

Description

@matthieusieben
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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue identifies a malfunctionchange-patchThis proposes or provides a change that requires a patch releasehelp-wantedThis issue has an actionable itempr-welcomeThis issue has an approved change; a pull request would be appreciated

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions