Skip to content

fix: unused printf tokens no longer consume the +ms suffix - #1059

Open
Pitchfork-and-Torch wants to merge 1 commit into
debug-js:masterfrom
Pitchfork-and-Torch:cook/unused-format-ms-suffix
Open

Pitchfork-and-Torch wants to merge 1 commit into
debug-js:masterfrom
Pitchfork-and-Torch:cook/unused-format-ms-suffix

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown

Summary

Fixes #967.

When colors are enabled, formatArgs pushed the +ms duration as a trailing argument. util.formatWithOptions then substituted that value into any unused %s / %d in the message (e.g. debug('hello %s') printed hello +0ms).

Fix

Append the colored +ms suffix to the format string instead of pushing a separate argument, consistent with how the non-color path embeds the timestamp.

Test plan

  • Manual: DEBUG_COLORS=yes unused %s keeps literal %s and still shows +Nms; supplied args still format correctly

When colors are enabled, formatArgs pushed the duration as a trailing
argument. util.format then substituted that value into any unused %s/%d
in the message (issue debug-js#967). Append the colored +ms suffix to the format
string instead, matching how the non-color path embeds the timestamp.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Unused format specifiers are not escaped.

1 participant