Created
August 4, 2019 17:17
-
-
Save faridv/9424e519772bec775cbfc50832879145 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function takeOverConsole() { | |
var console = window.console; | |
function intercept(method) { | |
var original = console[method]; | |
console[method] = function () { | |
var message = Array.prototype.slice.apply(arguments).join(' '); | |
original.call(console, arguments); | |
var xhr = new XMLHttpRequest(); | |
// xhr.open('get', '/log.php?error=' + message); | |
xhr.open('get', '/log.php?error=' + JSON.stringify(arguments)); | |
xhr.send(); | |
} | |
} | |
// var methods = ['warn', 'error'] | |
var methods = ['error']; | |
for (var i = 0; i < methods.length; i++) | |
intercept(methods[i]); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment