An AWS Firehose extension for the Bunyan logger
inspired by [@crccheck/kinesis-streams]
npm install bunyan-firehose
const bunyan = require('bunyan');
const { createFirehoseStream } = require('bunyan-firehose');
const firehoseConfig = {
accessKeyId: '<YOUR-ACCESS_KEY_ID',
secretAccessKey: '<YOUR_SECRET_ACCESS_KEY>',
streamName: 'logs-stream',
region: 'eu-west-1'
};
const firehoseStream = createFirehoseStream(firehoseConfig);
firehoseStream.on('error', (err) => {
console.error(`Firehose log error: `, err);
});
const logger = bunyan.createLogger({
name: name,
level: 'info',
serializers: bunyan.stdSerializers,
streams: [
{ stream: process.stdout, level: 'info' },
{ stream: firehoseStream, type: 'raw'}
]
});
logger.info({ msg: 'Writing info here', data: 'bla' });
logger.info('A regular string converted to json');
logger.warn('A simple warning');