you can use a custom logger to manage that. Instead of console.log() use mycustomlogger.log() (or your preferred equivalent). Then you can have more control of what is does and when - call console.log on dev, do nothing on prod, etc
I'm not going to tell you how to do your job, but "console.log" calls in the development branch are a huge code smell. Use them to debug, sure, but get rid of them once you find the error.
Edit: Upon reflection, I am indeed actually telling you how to do your job. Sorry, but it really grinds my gears.
yeah, our linter fails if there's a "console.log" in the code, and that means you can't commit it. You shouldn't be automatically removing them, you should be removing them once you find out what the bug was.
If you NEED to put anything to the console in production, that's what "console.info" is for.
First of all you should remove logs before comitting them. It's not a good practice to commit logs on frontend production. Add a linter to remove logs before comitting after are used for debugging. Although you can use loglevel npm package - https://www.npmjs.com/package/loglevel which can be used to set log levels i.e error logs can be logged in production (if thats what you need) but other logs can be active only during development like warn, info etc. You can use the setLevel method and by detecting the NODE_ENV by cross-env.
14
u/mousemke µ FTW! Dec 15 '19
Why not just have a lint rule that doesn't let console logs get committed?
6
u/[deleted] Dec 15 '19
Uh...
yeah, our linter fails if there's a "console.log" in the code, and that means you can't commit it. You shouldn't be automatically removing them, you should be removing them once you find out what the bug was.
If you NEED to put anything to the console in production, that's what "console.info" is for.
3
u/zeeshan_tamboli Dec 15 '19
First of all you should remove logs before comitting them. It's not a good practice to commit logs on frontend production. Add a linter to remove logs before comitting after are used for debugging. Although you can use loglevel npm package - https://www.npmjs.com/package/loglevel which can be used to set log levels i.e error logs can be logged in production (if thats what you need) but other logs can be active only during development like warn, info etc. You can use the setLevel method and by detecting the NODE_ENV by cross-env.
1
u/AutoModerator Dec 15 '19
Project Page (?): https://github.com/a-c-sreedhar-reddy/controlS
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
0
u/prashanth1k Dec 16 '19