I am using cordova to build my app.
I want to hide all logs created by console.log in production app.
But I could not find any solution to disable it.
Is this really possible to hide console logs ?
I'll really appreciate any contribution.
Thanks
Regards
I am using cordova to build my app.
I want to hide all logs created by console.log in production app.
But I could not find any solution to disable it.
Is this really possible to hide console logs ?
I'll really appreciate any contribution.
Thanks
Regards
javascript
Share
Improve this question
edited Jun 17, 2016 at 15:45
user177800
asked Jun 17, 2016 at 15:40
user2899728user28997282,31944 gold badges1818 silver badges2828 bronze badges4
2console.log is plain JS, nothing to do with Cordova or Ionic.
– C14L
CommentedJun 17, 2016 at 15:42
yes I know but I used thousands of console.log(); I am using it for debugging purpose. I don't want to remove all those so that I can re-use them in future to debug any issue. But for now I just want some way to hide all of those logs instead of removing lines manually.
– user2899728
CommentedJun 17, 2016 at 15:43
1I wrote my own Logger class, which allows me to set a level for debugging messages and enable/disable it. That way, I only go through my Logger layer and avoid console.log being used directly. That said, for simplicity, you could just override the console.log function with an empty function block, as described by C14L below. If the console isn't being displayed, then it's not really going to do any massive harm to leave those log statements in there. It may help you debug production problems to at least have SOME console.log statements remaining. Or remove them prior to release. Up to you.
– ManoDestra
CommentedJun 17, 2016 at 15:50
1Are you minifying your code for production? This should strip out any console.logs
– Geraint
CommentedJun 17, 2016 at 15:57
Add a ment
|
1 Answer
1
Reset to default
6
You could just override the log method of the console object.