Created
September 22, 2014 14:04
-
-
Save imjoshdean/18dad734f60ded6a6c1c to your computer and use it in GitHub Desktop.
console overloading with AJAX
This file contains hidden or 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
var logs = ['log', 'debug', 'info', 'warn', 'error']; | |
logs.forEach(function(log) { | |
var func = console[log]; | |
console[log] = function() { | |
var str = JSON.stringify(arguments); | |
// Run default version of console function | |
func.apply(console, arguments); | |
$.ajax({ | |
url: '/log', | |
type: 'POST', | |
data: { | |
log: str, | |
type: log | |
} | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment