Created
July 30, 2011 10:24
-
-
Save aziz/1115388 to your computer and use it in GitHub Desktop.
Manage Debug
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
//Call this function after body load | |
function manageDebug(){ | |
var debug = false; | |
if(window.console){ | |
var consoleBackUp = window.console.log; | |
window.console.log = function(str){ | |
if(debug){ | |
consoleBackUp.call(this,str); | |
} | |
} | |
}else{ | |
var log = window.opera ? window.opera.postError : alert; | |
window.console = {}; | |
window.console.log = function(str){ | |
if(debug){ | |
log(str); | |
} | |
} | |
} | |
} //manageDebug ends | |
manageDebug(); | |
console.log("This works!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment