I am using console.log
invocations pretty extensively during development of javascript code. I wouldn't like to include these debug logs in the production code and wouldn't like to remove them permanently.
The somewhat obvious solution would be to process/filter javascript sources at the time of deployment on production server. The minimal approach would be to use grep -v console.log sample.js
but it will break the code in case of multi-line or complex statements.
The javascript code is actually a template (jinja2) of javascript code but I care to keep it syntactically correct (I put templater tags in comments, strings, etc.).
Is there a smart method of doing it or I have to assume that console.log
statements must be single line and the line mustn't contain other, non-debug code?