Update in-browser logging to accommodate n-args

This commit is contained in:
wltsmrz
2013-12-23 11:48:39 -08:00
parent 6cdeacdb90
commit 627acdbfde

View File

@@ -3,9 +3,17 @@ var exports = module.exports = require('./utils.js');
// We override this function for browsers, because they print objects nicer
// natively than JSON.stringify can.
exports.logObject = function (msg, obj) {
if (/MSIE/.test(navigator.userAgent)) {
console.log(msg, JSON.stringify(obj));
} else {
console.log(msg, "", obj);
}
var args = Array.prototype.slice.call(arguments, 1);
args = args.map(function(arg) {
if (/MSIE/.test(navigator.userAgent)) {
return JSON.stringify(arg, null, 2);
} else {
return arg;
}
});
args.unshift(msg);
console.log.apply(console, args);
};