socket.io seems to have a basically sensible logging system for all its internals. How do I get at that logging object myself so I can generate my own log messages at appropriate levels? It bugs me that my console.log() messages are un-timestamped, un-leveled, and ugly next to the socket.io messages. I’ve done a bunch of spelunking in the socket.io code and I’m just not savvy enough about node at this point to understand what the object hierarchies look like to know how to get at the object I want from my code.
Longer term, I’m probably going to want a more robust logging system module (with the ability to log to files, auto-rotate, manage levels on a per-module basis, custom log levels, etc.). Winston looks sensible, but can I get socket.io to use it, too? It’d be nice to have everything in one place.
While using socket.io, I was able to plug into the existing logger module like so:
Configuring the logger is also very simple: