Sails Persistence Logger
Automatically log all Sails model persistence events
Install
npm install --save sails-persistence-logger
Use
To use Sails Persistence Logger out of the box add the logger to config/models.js
default persistence hooks so it looks like the following example:
var SailsPersistenceLogger = ;var logger = ; moduleexportsmodels = { sailsPersistenceLogger; } { sailsPersistenceLogger; } { sailsPersistenceLogger; };
And that's it! You'll now have Log4js logging of the form [2017-03-19 15:03:27.608] [INFO] sails-persistence-logger - Created event 42
for all persistence events.
API
require('sails-persistence-logger')(options: Object)
Initializes Sails Persistence Logger with the given options. All options are optional.
-
options.logger
: Log4js compatible logger which Sails Persistence Logger will use -
options.level
: (default: info) Log4js logging level ('debug', 'info', 'warn', 'error') -
options.exclude
: Object used to exclude full models or specific methods on a model from logging-
Example option excluding all
video
model logging and updates onreview
model logging:{ video: true, review: ['UPDATE'] // Allowed options are ['CREATE', 'UPDATE', 'DESTROY'] }
-