Skip to content

Instantly share code, notes, and snippets.

@imjoshdean
Created September 22, 2014 14:04
Show Gist options
  • Save imjoshdean/18dad734f60ded6a6c1c to your computer and use it in GitHub Desktop.
Save imjoshdean/18dad734f60ded6a6c1c to your computer and use it in GitHub Desktop.
console overloading with AJAX
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