Skip to content

Integrates winston logging system with your Sails application

License

Notifications You must be signed in to change notification settings

AndruBot/sails-hook-winston

 
 

Repository files navigation

sails-hook-winston

Build Status Dependency status Dev Dependencies Status NPM Status Gittip

Integrates winston logging system with your Sails application.

Install

Note: This library requires sails >= 0.11.0

npm install sails-hook-winston

Usage

winston is one of the most powerful logging libraries for NodeJS. You can unlock the feature of winston in your Sails application when you use this hook, in special use different transport.

At this moment, the transport supported are:

API

This library extend config/log and use the winston API for setup the Transport. This is an example of configuration:

var path = require('path');
var pkgJSON = require(path.resolve('package.json'));

module.exports.log = {

  // This options are for Console transport that is used by default
  level: 'silly', // you are familiar with this value, right?
  timestamp: true, // if you want to output the timestamp in the console transport

  // unlock dailyRorate transport!
  // more information: https://github.com/winstonjs/winston#daily-rotate-file-transport
  dailyRotate: {
    dirname: path.resolve('logs'),
    datePattern: '.yyyy-MM-dd.log',
    filename: pkgJSON.name,
    prettyPrint: true,
    timestamp: true,
    level: 'silly'
  },

  // unlock mongoDB transport!
  // more information: https://github.com/winstonjs/winston#mongodb-transport
  mongoDB: {
    level: 'silly',
    db: pkgJSON.name,
    collection: 'logs',
    host: 'localhost',
    port: 27017
  }
};

Note how the options are different for each transport. For example, you can use info level in console but store silly level in MongoDB.

License

MIT © Kiko Beats

About

Integrates winston logging system with your Sails application

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 84.2%
  • Shell 15.8%