Created
November 10, 2012 21:29
-
-
Save oroce/4052571 to your computer and use it in GitHub Desktop.
pipe bunyan logger into mongodb (even with node-restify)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}) | |
}] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
})); |
How does this connect to my database, that is, where do i specify my hostname and port?
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
very good!