From ffbbc465d3af25f207ea36a14a98014e9ca27b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Thu, 5 Aug 2010 11:38:11 +0200 Subject: [PATCH] Support inspecting objects with console.log If the first parameter passed into console.log() is not a string, all parameters will be printed as formated by sys.inspect. This change also affects console.info and console.warn. --- src/node.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/node.js b/src/node.js index 70a291739..d512dc44c 100644 --- a/src/node.js +++ b/src/node.js @@ -192,6 +192,15 @@ process.openStdin = function () { // console object var formatRegExp = /%[sdj]/g; function format (f) { + if (typeof f !== 'string') { + var objects = [], sys = module.requireNative('sys'); + for (var i = 0; i < arguments.length; i++) { + objects.push(sys.inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; var args = arguments; return String(f).replace(formatRegExp, function (x) {