Skip to content

Commit 9fe4c7d

Browse files
author
amandaesmith333
committed
capture all arguments sent to console method
1 parent b08f738 commit 9fe4c7d

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

static/usage/common.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,27 @@ window.addEventListener('DOMContentLoaded', () => {
3131
_warn = console.warn,
3232
_error = console.error;
3333

34-
const dispatchConsoleEvent = (type, message) => {
34+
const dispatchConsoleEvent = (type, arguments) => {
3535
window.dispatchEvent(new CustomEvent('console', {
3636
detail: {
3737
type,
38-
message
38+
message: Object.values(arguments).join(' ')
3939
}
4040
}));
4141
}
4242

43-
// TODO: is there an easy way to capture all args?
44-
// maybe turn vals into array, then do .join(' ')?
4543
console.log = function() {
46-
dispatchConsoleEvent('log', arguments[0]);
44+
dispatchConsoleEvent('log', arguments);
4745
return _log.apply(console, arguments);
4846
};
4947

5048
console.warn = function() {
51-
dispatchConsoleEvent('warning', arguments[0]);
49+
dispatchConsoleEvent('warning', arguments);
5250
return _warn.apply(console, arguments);
5351
};
5452

5553
console.error = function() {
56-
dispatchConsoleEvent('error', arguments[0]);
54+
dispatchConsoleEvent('error', arguments);
5755
return _error.apply(console, arguments);
5856
};
5957

static/usage/v7/range/ion-change-event/demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
const range = document.querySelector('ion-range');
3131

3232
range.addEventListener('ionChange', ({ detail }) => {
33-
console.log('ionChange emitted value: ' + detail.value);
33+
console.log('ionChange emitted value:', detail.value);
3434
});
3535
</script>
3636
</body>

0 commit comments

Comments
 (0)