vsync vsync - 4 months ago 6x
Javascript Question

How do I disable console.log when I am not debugging?

I have many

(or any other console calls) in my code and I would like to use them only
when my app is in some kind of "debug mode".

I can't seem to use some kind of logger function and internally use
because then I wouldn't know what line fired it. Maybe only with a try/catch, but my logs are very general and I don't want try/catch in my code.

What would you recommend?


Nowdays, in 2014, I simply use GULP (and recommend everyone to, it's an amazing tool), and I have a package installed which is called stripDebug which does that for you.

(I also use uglify and closureCompiler in production)