Yesterday I learned about winston – a logging library for node. #200wordsTIL
I don't know why Winston is called Winston it's not a very obvious name for a console.log alternative and that's the cool thing about livecoding: People tell you stuff.
So winston is a logger for node.
What's a logger you might ask? A logger is a "service" that lets you collect logs from your code and send them to an output.
The benefit of Winston over console.log is that:
1) You get prettier output. JSON highlights etc.
2) You get log levels. logger.debug, logger.info, things like that.
Log levels are great when you want to jump between dev and prod modes.
However Winston also has a funny side-effect. It expects to always get a message and an object.
So if you call logger.debug("my string looks like", string)
You are made painfully aware that strings are arrays also.
So that was fun. Winston is cool. Consider giving him a shot next time you write a lot of console logs.