Skip to content

Logging

Risabh Kumar edited this page Jul 6, 2018 · 1 revision

A winston logger is configured and made available for use at /src/utils/logger.

Try to to use it instead of console calls for events and checkpoints.

Make sure not to log any sensitive data using winston. Use console for them.


Why Winston?

Although console calls are desirable and easy to use while developing the app, winston's transport feature comes very handy in production. The logs generated can easily be consumed by a 3rd party log viewer for insights.

Currently configured to write errors in error.log file and info, warn and errors in combined.log, it can be easily ported to use any of the transports available ranging from MongoDB to AWS CloudWatch and everything in between.

winston-irc or slack-webhook-transport can be used in future to log errors to the team’s channel. This will come in very handy to report errors when app runs on production.

Also, once the application starts to grow, chances are we will want to have multiple loggers with different configurations where each logger is responsible for a different feature area. This is easily possible with winston by adding new winston.loggers or winston.Container or simply adding categories.

Profiling, Handling exceptions and Querying Logs are few to name among the features winston provides.

Clone this wiki locally