Package Exports
- bole-mongodb
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bole-mongodb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
bole-mongodb
MongoDB stream for the bole logger
Plugin for the bole logger. Saves the logs to a MongoDB collection, log by default.
var bole = require ("bole");
var boleMongo = require ("bole-mongodb");
var url = ...
MongoClient.connect (url, function (error, db){
if (error) return console.error (error);
var boleMongoStream = boleMongo ({ db: db, capped: true })
//The error handler shouldn't be called. If it is called, then something is
//wrong with the database url or connection options, so it's up to you
//how to handle these kind of errors: crashing the server (without
//registering this error handler) or logging it somewhere
.on ("error", console.error);
bole.output ([
{ level: 'error', stream: boleMongoStream }
]);
...
});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 for the first time a message is logged, and it can be forced to convert an existing one into a capped collection.
Returns a new Writable stream instance.
Options:
- db - Object
MongoDBDbinstance. This option is mandatory. - collection - String
Name of the collection. Default "log". - capped - Boolean
If the collection doesn't exist, creates a new capped collection. Default false. - size - Number
Size 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.
