I have some console.log commands spread through my site.
Is it possible to override console.log with my own function? I want to customize the function so that it only logs if a specific variable is set to true.
In the end, I would still need to call the real console.log from this function.
Thanks
Kevin
Just create a closure, and store the original
console.logfunction in a local variable.Then override
console.log, and call the original function after you do your check:Here’s the fiddle: http://jsfiddle.net/J46w8/