Skip to content

Instantly share code, notes, and snippets.

@peanutbother
Created July 25, 2016 23:02
Show Gist options
  • Save peanutbother/9becc3372ff963860e86a8ae269a3ce5 to your computer and use it in GitHub Desktop.
Save peanutbother/9becc3372ff963860e86a8ae269a3ce5 to your computer and use it in GitHub Desktop.
Disable console.log for on website
// backup console object
var debug = console;
//create Console Class
var Console;
(Console = function (showError) {
if (typeof showError == 'boolean') {
this.showError = showError;
}
}).prototype = {
showError: false;
log: function (){
if(this.showError) {
debug.error("console is deactivated, use debug instead");
}
}
}
/*
* overwrite default console object with own Class instance
*
* if object is constructed with TRUE as parameter, each usage of console.log()
* will raise an error to console
*/
console = new Console();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment