Last active
August 29, 2015 13:56
-
-
Save mpjura/9291832 to your computer and use it in GitHub Desktop.
Overwrite console to only run when debug conditions are met
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
(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