sails-generate-request-log

0.10.1 • Public • Published

sails-generate-request-log

A request-log generator for use with the Sails command-line interface.

Certain generators are installed by default in Sails, but they can be overridden. Other generators create entirely new things. Check the Sails docs for information on installing generator overrides / custom generators and information on building your own generators.

Installation

$ npm install sails-generate-request-log

Usage

On the command line
$ sails generate request-log 

Adding logging to middleware

To enable request logging you'll need to add the logger to your existing middleware stack in config/http.js, like so:

//require the logger
var logger = require('./requestLogger')
module.exports.http = {

  middleware: {

    order: [
      'startRequestTimer',
      'cookieParser',
      'session',
      //add a custom logging function
      'requestLogger',
      'bodyParser',
      'handleBodyParserError',
      'compress',
      'methodOverride',
      'poweredBy',
      '$custom',
      'router',
      'www',
      'favicon',
      '404',
      '500'
    ],

    //define the custom logging function you referenced in the above order
    requestLogger: logger.requestLogger

  }

Development

Also see CONTRIBUTING.md for more information on overriding/enhancing existing generators.

Questions?

See FAQ.md.

More Resources

License

MIT © 2015 balderdashy & contributors

As for Sails? It's free and open-source under the MIT License.

image_squidhome@2x.png

Package Sidebar

Install

npm i sails-generate-request-log

Weekly Downloads

2

Version

0.10.1

License

MIT

Last publish

Collaborators

  • chris-held