🚀 DAY 4 OF LAUNCH WEEK:Introducing Socket Scanning for OpenVSX Extensions.Learn more →
Socket
Book a DemoInstallSign in
Socket

mongoose-events-event-logger

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-events-event-logger

creates a mongoose event handler that logs mongoose events for the given event type

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

mongoose-events-logger

NPM version Build Status Coverage Status NSP Status

creates a mongoose event handler that logs mongoose events for the given event type using console.log and console.error.

table of contents

installation

npm install mongoose-events-event-logger

api

/**
 * @param {string} event_type
 * @param {Object} db_connection
 * @param {Object} [custom_logger]
 *
 * @return {Function} logEvent
 */
createEventLogger( event_type, db_connection, custom_logger )

event types

  • connected
  • connecting
  • disconnected
  • error
  • open
  • reconnected

usage

add an event logger to the mongoose db connection for each event type you want to log. the event logger will default to using the console to log events, however, you can optionally pass in your own logging service.

the log message is composed using new Date() and the db connection info; e.g. [info] %date connected to mongodb://%host:%port/%database

basic

var createEventLogger = require( 'mongoose-events-event-logger' )
var db

db = mongoose.connection
db.on( 'connected', createEventLogger( 'connected', db ) )

with a custom logger

var eventLogger = require( 'mongoose-events-event-logger' )
var db

// logging service needs to have a .log( arg1[, arg2[, ...] ] ) method
var logger = require( 'your-custom-logger' )

db = mongoose.connection
db.on( 'connected', createEventLogger( 'connected', db, logger ) )

license

MIT License

Keywords

mongoose event logger

FAQs

Package last updated on 19 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts