Simple Logging in Node JS using MongoDB
JavaScript
Switch branches/tags
Nothing to show
Latest commit 16bc7b6 Jun 18, 2013 @astalker Added licence
Permalink
Failed to load latest commit information.
.gitignore
LICENSE.md
README.md
logmongo.js
package.json

README.md

LOGMONGO

Simple logging for Node using MongoDB.

Installation

$ npm install logmongo

Usage

Add the following to your main script and specify your login details for the Admin.

var logger = require('logmongo');
logger.connect('mongodb://localhost/log');
logger.log('login', 1);

If your App already connects to Mongo then you can use the same Database and miss out the connect call.

To display existing logs:

var util = require('util'), log = require('logmongo.js');
log.connect('mongodb://localhost/log');
log.forAll(function(error, row) {
    util.log('ROW: ' + util.inspect(row));
}, function(error) {
    if (error) throw error;
    util.log('ALL DONE');
    log.disconnect(function(err) { });
});