Browse Source

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.
v0.7.4-release
Felix Geisendörfer 15 years ago
committed by Ryan Dahl
parent
commit
ffbbc465d3
  1. 9
      src/node.js

9
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) {

Loading…
Cancel
Save