Skip to content

Instantly share code, notes, and snippets.

@mpjura
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpjura/9291832 to your computer and use it in GitHub Desktop.
Save mpjura/9291832 to your computer and use it in GitHub Desktop.
Overwrite console to only run when debug conditions are met
(function( window ){
var console = window.console;
var methods = ["log","dir"],
old = {};
//TODO - set this via query param or whatever you want
var debug = true;
for ( var i = 0, len = methods.length; i < len; i++ ) {
old[ methods[i] ] = console[ methods[i] ];
console[ methods[i] ] = function(){
if ( !debug ){ return; }
old[ methods[i] ].apply( console, [].slice.call( arguments, 0 ) );
}
}
})( this );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment