smith-and-winston

0.3.0 • Public • Published

smith-and-winston

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).

Installation

$ npm install smith-and-winston --save

Usage

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);

Disabling Defaults

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

Defaults are everything to Smith and Winston. Here is the basic structure:

{
  file: {},
  console: {},
  colors: {}
}

Default file options:

{
  level: 'info',
  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'
}

Licence

MIT. See "LICENSE.MIT".

Credits

Package Sidebar

Install

npm i smith-and-winston

Weekly Downloads

1

Version

0.3.0

License

MIT

Last publish

Collaborators

  • dproteau