Skip to content

Instantly share code, notes, and snippets.

@oroce
Created November 10, 2012 21:29
Show Gist options
  • Save oroce/4052571 to your computer and use it in GitHub Desktop.
Save oroce/4052571 to your computer and use it in GitHub Desktop.
pipe bunyan logger into mongodb (even with node-restify)
var mongoCol = require( "mongo-col" ),
mongoStream = require( "mongo-stream" ),
mongoInsertStream = mongoStream( mongoCol( "piped-collection", null, {
dbOptions:{
safe: true
}
})),
Logger = require( "bunyan" );
new Logger({
name: "pipe-into-mongodb",
streams: [{
type: "raw",
stream: mongoInsertStream.insert({
safe: true
})
}]
});
var mongoCol = require( "mongo-col" ),
mongoStream = require( "mongo-stream" ),
restify = require( "restify" ),
mongoInsertStream = mongoStream( mongoCol( "piped-collection", null, {
dbOptions:{
safe: true
}
})),
Logger = require( "bunyan" ),
server = restify.createServer();
var logger = new Logger({
name: "pipe-into-mongodb",
streams: [{
type: "raw",
stream: mongoInsertStream.insert({
safe: true
})
}]
});
server.on( "after", restify.auditLogger({
log: logger
}));
@bromanko
Copy link

Where are mongo-col and mongo-stream coming from?

@bromanko
Copy link

@karboom
Copy link

karboom commented Mar 27, 2015

very good!

@sabrehagen
Copy link

How does this connect to my database, that is, where do i specify my hostname and port?

@chrisvdb
Copy link

chrisvdb commented Jun 3, 2015

Would somebody be able/willing to provide a bit more context on how this works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment