Created
November 6, 2011 13:21
-
-
Save ruiwen/1342867 to your computer and use it in GitHub Desktop.
Silence window.console.log on demand
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
/** | |
* | |
* Neuters console.log, and makes its output dependent on the global boolean DEBUG | |
* | |
**/ | |
window.DEBUG = false; | |
window.console._log = window.console.log; // Make sure we have a pointer to the original function | |
window.console.log = function(str) { | |
if(window.DEBUG) { | |
window.console._log(str); | |
} | |
} | |
// Single line version | |
//window.console.log = function(str) { if(window.DEBUG) { window.console._log(str); } } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment