Smith and Winston is a wrapper around Winston aiming to reduce configuration code.
Its goal is to provide a logger properly configured to my needs without great ceremony. With the default configuration, we output to the console string messages (debug level) and write to a flat file json messages (info level).
$ npm install smith-and-winston --save
Simply:
var Smith = require('smith-and-winston');
var winston = new Smith();
Hum... the app log file is too small and needs a new home:
var Smith = require('smith-and-winston');
var options = {file: {
filename: '/var/log/myGreatApp/main.log',
maxsize: 26214400 //25MB
}}
var winston = new Smith(options);
To disable one of the default, just put null.
To get back Winston default colors:
var Smith = require('smith-and-winston');
var options = {colors: null};
var winston = new Smith(options);
To disable the File transport:
var Smith = require('smith-and-winston');
var options = {file: null};
var winston = new Smith(options);
Defaults are everything to Smith and Winston. Here is the basic structure:
{
file: {},
console: {},
colors: {}
}
Default file options:
{
level: 'warn',
filename: './logs/app.log',
handleExceptions: true,
json: true,
maxsize: 5242880, //5MB
maxFiles: 5,
colorize: false
}
Default console options:
{
level: 'debug',
timestamp: true,
handleExceptions: true,
json: false,
colorize: true
}
Default colors:
{
debug: 'cyan',
info: 'green',
warn: 'yellow',
error: 'red'
}
MIT. See "LICENSE.MIT".
- [Winston] (https://github.com/winstonjs/winston) and to all its contributors
- Ugo Lattanzi [Advanced logging with NodeJs] (http://tostring.it/2014/06/23/advanced-logging-with-nodejs/)