Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 5b988de

Browse files
committed
make console.log accept multiple arguments and more styling
1 parent fa110cc commit 5b988de

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

public/js/debug-console.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
["log", "warn", "error"].forEach(function(func) {
88
window.console[func] = function(msg) {
99
var style = null;
10-
if (arguments[2] && arguments[0].indexOf('%c') > -1) {
10+
var messages = Array.prototype.slice.call(arguments);
11+
if (arguments[0].indexOf('%c') > -1 && arguments.length > 1) {
1112
style = arguments[1];
13+
messages.splice(1, 1); // remove style string from console output
1214
}
15+
1316
var data = {
14-
msg: JSON.stringify(JSON.decycle(msg, true), null, ' '),
17+
msg: messages.map(toMessage).join(' '),
1518
style: style,
1619
type: func
1720
};
@@ -36,6 +39,10 @@
3639
return false;
3740
};
3841

42+
function toMessage (msg) {
43+
return JSON.stringify(JSON.decycle(msg, true), null, ' ');
44+
}
45+
3946
function downloadFile() {
4047
window.opener.postMessage(JSON.stringify({ downloadFile: arguments }), 'file://');
4148
}

0 commit comments

Comments
 (0)