Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

console.log formatting has no escape #1273

Closed
onnlucky opened this Issue Jul 5, 2011 · 5 comments

Comments

Projects
None yet
4 participants

onnlucky commented Jul 5, 2011

not sure if I like console.log formatting "%d" and such, since browsers don't do it ... but worse, there is no way to escape it

var formatRegExp = /%[sdj]/g;

should be something like

var formatRegExp = /%[%sdj]/g;

and "%%" should become one "%" in the replace function ... or the escaping should be left alone if there are no arguments to match it

but anyway you slice it, if you print % signs to console.log browser behavior will differ from nodejs behavior

We should support %% to escape it. That's definitely a bug.

Just because it isn't done in a browser isn't a good reason to get rid of something. Changing this would also break a large percentage of code already out there.

I agree it is likely too late now, and who prints stuff to the browser log that is supposed to be meaningfully parsed later ... But still, taking an existing and known API and changing it slightly in semantics is something best avoided. But that is just an opinion.

@koichik koichik added a commit to koichik/node that referenced this issue Jul 30, 2011

@koichik koichik Add %% escape to util.format()
Fixes #1273.
83d17f6

koichik commented Jul 30, 2011

+1. Can I merge 83d17f6?

Owner

bnoordhuis commented Jul 30, 2011

@koichik: LGTM

koichik commented Jul 30, 2011

@bnoordhuis - Thanks!

@koichik koichik closed this in d3d8f1b Jul 30, 2011

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