2 ms·
I don't use console.log when I can. It's better to roll your own logging function which adds timestamps and automatically stringifies the object (preferably usi
by nawitus 12y ago
I don't use console.log when I can. It's better to roll your own logging function which adds timestamps and automatically stringifies the object (preferably using a stringify function which handles cyclic objects).
The prolem with using console.log(object) is that in Node.js the object is not stringified and on browsers the debugger displays the current state of the object, not the state when it was printed. I found that out the hard way..
And when you're using your own logging function you can use a proper logging framework like winston to save the logs to a database and a file in addition to the console (we also send client-side logs to the backend using socket.io for easy debugging).