Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bole-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bole-mongodb

MongoDB stream for the bole logger

  • 0.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

bole-mongodb

MongoDB stream for the bole logger

npm

Plugin for the bole logger. Saves the logs to a MongoDB collection, log by default.

var bole = require('bole');
var boleMongo = require('bole-mongodb');

MongoClient.connect(url, function (err, db) {
  if (err) return console.error(err);
  
  var boleMongoStream = boleMongo({ db: db, capped: true })
    .on('error', console.error);
  
  bole.output([
    { level: 'error', stream: boleMongoStream }
  ]);

  var log = bole('my-module');
 });

The Db object is required. Instead of opening a new connection from inside the plugin, the user is responsible for the connection's lifecycle. Therefore, this plugin assumes that the connection is already open. However, it won't fail if it's not.

MongoDB has the concept of a Capped collection and it can be used for logging purposes. This plugin tries to create a capped collection each time a message is logged. Therefore, it's not required to have the connection open at the time of registering the plugin.

module(options) : Writable
Returns a new Writable stream instance.

Options:

  • db - Object
    MongoDB Db instance. This option is mandatory.
  • collection - String
    Name of the collection. Default logs.
  • capped - Boolean
    If the collection doesn't exist, creates a new capped collection. Default false.
  • size - Number
    Size in bytes of the capped collection. Default 10000000 (10MB rounded up to the nearest multiple of 256).
  • max - Number
    Maximum number of documents allowed in the capped collection. Default undefined.
  • force - Boolean
    If the collection already exists, it is converted into a capped collection. Default false.

Keywords

FAQs

Package last updated on 17 Jan 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc