Skip to content

Instantly share code, notes, and snippets.

@shanghaikid
Last active January 14, 2019 07:32
Show Gist options
  • Save shanghaikid/afa4d493b07f383ed60d39c8abba4f1e to your computer and use it in GitHub Desktop.
Save shanghaikid/afa4d493b07f383ed60d39c8abba4f1e to your computer and use it in GitHub Desktop.
save log fed error
const {error, log} = console;
Object.defineProperties(console, {
'saveLog': {
value: function() {
// put backend request here in the try catch error
alert('sent', arguments);
}
},
'log': {
value: function() {
log.apply(this, arguments);
console.saveLog.apply(this, arguments);
}
},
'error': {
value: function() {
error.apply(this, arguments);
console.saveLog.apply(this, arguments);
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment