'Enable/Disable console.log in production version

Based on a flag I want to enable or disable the console.log in the production versions. But I don't want to expose that option to my users because then everyone will ask about it and waste my time.

If I allow such flag to be stored in user preferences thru the Options dialog, till those preferences are loaded, my code will be spewing out the console.log output till that flag is loaded from the chrome storage.

I can create a debug flag cookie using extensions but unfortunately my extension works on many sites.

If I disable console.log altogether in production versions but when clients face problem then at that moment I'll not be able to look into the console.log to debug it. So this is not feasible.

Is there any what my extension can know from the first line that console.log needs to be bypassed or not every time the extension is run( includes BG script, content script and the options dialog)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source