Last active
August 29, 2015 13:57
-
-
Save gowon/9800287 to your computer and use it in GitHub Desktop.
Wrapper for console.log
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
//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)); |
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(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