Last active
May 29, 2017 16:28
-
-
Save delvedor/10331afd1a3b4673f865d1b2ccc9c114 to your computer and use it in GitHub Desktop.
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
const Pino = require('pino') | |
const spawn = require('child_process').spawn | |
const { MONGO_ADDRESS } = process.env | |
function eventLogger () { | |
const mongoLog = spawnMongoLog() | |
mongoLog.on('error', err => { throw err }) | |
mongoLog.stdout.pipe(process.stdout) | |
const pino = Pino({ | |
name: 'letzdoit-events', | |
level: 'info' | |
}, mongoLog.stdin) | |
return pino | |
} | |
function spawnMongoLog () { | |
return spawn( | |
'./node_modules/.bin/pino-mongodb', | |
[ | |
'--host', MONGO_ADDRESS, | |
'--collection', 'logs' | |
] | |
) | |
} | |
module.exports = eventLogger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment