From e15221a8dee8383550cef15638f42c6fcf9ba0f8 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Thu, 5 Aug 2010 10:15:22 -0700 Subject: [PATCH] console formatter appends extra arguments This makes the console methods more "browser-like", for example: console.log("foo", "bar", "baz"); // foo bar baz but still works with formatting console.log("hey %s", "tj", "whats up"); // hey tj whats up --- src/node.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index d512dc44c6..8a92418911 100644 --- a/src/node.js +++ b/src/node.js @@ -203,7 +203,7 @@ function format (f) { var i = 1; var args = arguments; - return String(f).replace(formatRegExp, function (x) { + var str = String(f).replace(formatRegExp, function (x) { switch (x) { case '%s': return args[i++]; case '%d': return +args[i++]; @@ -212,6 +212,10 @@ function format (f) { return x; } }); + for (var len = args.length; i < len; ++i) { + str += ' ' + args[i]; + } + return str; } global.console = {};