Log from within the runner to get proper object.

This commit is contained in:
Tom Ashworth 2013-07-01 15:53:52 +01:00
parent af6310ec76
commit 98e632498a
2 changed files with 10 additions and 5 deletions

View File

@ -247,26 +247,26 @@ window._console = {
for (; i < l; i++) {
log(''+arguments[i], true);
}
window.console.log.apply(window.console, arguments);
// window.console.log.apply(window.console, arguments);
},
dir: function () {
var l = arguments.length, i = 0;
for (; i < l; i++) {
log(arguments[i]);
}
window.console.dir.apply(window.console, arguments);
// window.console.dir.apply(window.console, arguments);
},
props: function (obj) {
var props = [], realObj;
try {
for (var p in obj) props.push(p);
} catch (e) {}
window.console.props.apply(window.console, arguments);
// window.console.props.apply(window.console, arguments);
return props;
},
error: function (err) {
log(err.message || err, 'error');
window.console.error.apply(window.console, arguments);
// window.console.error.apply(window.console, arguments);
}
};

View File

@ -71,7 +71,7 @@ var proxyconsole = (function () {
// Create each of these methods on the proxy, and postMessage up to JS Bin
// when one is called.
var methods = ['debug', 'error', 'info', 'log', 'warn', 'dir'];
var methods = ['debug', 'error', 'info', 'log', 'warn', 'dir', 'props'];
methods.forEach(function (method) {
// Create console method
proxyconsole[method] = function () {
@ -83,6 +83,11 @@ var proxyconsole = (function () {
method: method,
args: JSON.stringify(args)
});
// If the browner supports it, use the browser console
if (window.console) {
if (!console[method]) method = 'log';
console[method].apply(console, originalArgs);
}
};
});