Skip to content

Instantly share code, notes, and snippets.

@gowon
Last active August 29, 2015 13:57
Show Gist options
  • Save gowon/9800287 to your computer and use it in GitHub Desktop.
Save gowon/9800287 to your computer and use it in GitHub Desktop.
Wrapper for console.log
//TODO: http://stackoverflow.com/questions/7042611/override-console-log-for-production
;
(function (window) {
if (window.log) {
return;
}
window.log = function() {
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if ((Array.prototype.slice.call(arguments)).length == 1 && typeof Array.prototype.slice.call(arguments)[0] == 'string') {
console.log((Array.prototype.slice.call(arguments)).toString());
} else {
console.log(Array.prototype.slice.call(arguments));
}
};
}(window));
(function(a){if(a.log){return}a.log=function(){log.history=log.history||[];log.history.push(arguments);if((Array.prototype.slice.call(arguments)).length==1&&typeof Array.prototype.slice.call(arguments)[0]=="string"){console.log((Array.prototype.slice.call(arguments)).toString())}else{console.log(Array.prototype.slice.call(arguments))}}}(window));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment