@nahanil/sails-hook-api-log

1.0.0 • Public • Published

@nahanil/sails-hook-api-log

Terse request logging for Sails.js applications.

Forked from Mike McNeil's pretty awesome sails-hook-apianalytics.

Install

yarn add @nahanil/sails-hook-api-log

That's it! Next time you lift, and then send a request to the server, you should see stuff getting logged.

Configuration

Optionally, you can customize this hook in a few different ways by configuring sails.config['api-log].

For instance, you might create config/api-log.js:

module.exports = {
  'api-log': {
    /**
     * An array of route addresses to monitor.
     *
     * (e.g. [ 'GET /foo/bar', 'POST /foo', 'all /admin/*' ])
     *
     * Defaults to logging all POST, PATCH, PUT, DELETE requests, and all
     * GET requests except for those that appear to be for assets
     * (i.e. using "GET r|^((?![^?]*\\/[^?\\/]+\\.[^?\\/]+(\\?.*)?).)*$|")
     */
    routesToLog: [
      // If you want to log everything- including requests for assets, use the following:
      '/*'
    ],

    /**
     * Custom log function
     * Uses `console.log` by default and recieves the text string that would be logged
     */
    logFn: (str) => {
      console.log(`APILOG: ${str}`)
    }
  }
}

Package Sidebar

Install

npm i @nahanil/sails-hook-api-log

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

7.73 kB

Total Files

6

Last publish

Collaborators

  • nahanil