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 hidden or 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 hidden or 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 | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would somebody be able/willing to provide a bit more context on how this works?