winston-formatted
Wrapper around the the fantastic winston
logging library which adds formatting and colorization, and filename of the file calling the logger method.
This library adds a helper method loggerFor()
to the winston
object, which creates and returns a Console transport with formatting:
const log = winston;
Motivation
Having used winston
in many projects myself, I found that I wanted a nice console output and a bit more information, so I've spent some time to write a wrapper around winston
to do just that.
Installation
npm install --save winston-formatted
Usage
The intention is that you can use winston
as you normally would, with a formatted console output.
ES6 modules usage
;// passing in module here allows the library to get the calling filenameconst log = winston;// using normal methods for logginglog;log;log;log;log;log;
Logging levels
Logging levels in winston
conform to the severity ordering specified by [RFC5424]: severity of all levels is assumed to be numerically ascending from most important to least important.
const levels =error: 0warn: 1info: 2verbose: 3debug: 4silly: 5;
Advanced usage
The whole winston
library is passed through, and the logger returned is a normal winston
Console transport.
Therefore, you can do all the things you normally would with winston
. For instance, to add a File transport to your logger, with only 'error' level, do the following:
;const log = winston;// add more transports as requiredlog;
For full configuration options, please refer to winston
Credits
Kev Marchant
Author:Of course, all props go to the original authors of this great library.