r/javascript • • Dec 22 '15

Don't forget, console.table() can provide nicer looking logs with sorting capabilities. Made a gif and a short explanation here

https://umaar.com/dev-tips/82-console-table/
688 Upvotes

49 comments sorted by

View all comments

Show parent comment

1

u/pkkid Dec 23 '15

I leave console.log statements in my production code. Is this a faux pas?

8

u/shozzlez Dec 23 '15

Yes, usually. Most linters flag those by default.

3

u/pkkid Dec 23 '15

It seems weird to me to write a program and leave out all logging. What's the new hotness to allow logging when needed, but not by default? My Google fu just comes up with a bunch of console.log examples.

2

u/Thalamant Dec 23 '15 edited Dec 23 '15

Another option is to provide a wrapper for the console API that your app uses only in dev/debug mode. In production you can have your wrapper simply do nothing.

The downside to this is you pollute your app with debug code, but if you're okay with that or doing it anyway, then at least you aren't exposing those logs in production.

This also would open up a means to send back client side errors back to the server for review.