Skip to content

Instantly share code, notes, and snippets.

@ruiwen
Created November 6, 2011 13:21
Show Gist options
  • Save ruiwen/1342867 to your computer and use it in GitHub Desktop.
Save ruiwen/1342867 to your computer and use it in GitHub Desktop.
Silence window.console.log on demand
/**
*
* 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