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.
This commit is contained in:
Родитель
6cd32fb62e
Коммит
ffbbc465d3
|
@ -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) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче