Skip to content

Eli-Goldberg/bunyan-firehose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bunyan-firehose

An AWS Firehose extension for the Bunyan logger

inspired by [@crccheck/kinesis-streams]

Installing

npm install bunyan-firehose

Writeable stream

'use strict'

const bunyan         = require('bunyan')
const bunyanFirehose = require('./src')
const AWS            = require('aws-sdk')

const config = {
  streamName:  'logs-stream',
  region:      'eu-west-1',
  credentials: new AWS.Credentials({
    accessKeyId:     '<ACCESS_KEY_ID',
    secretAccessKey: '<SECRET_ACCESS_KEY>',
    sessionToken:    '<SESSION_TOKEN>'
  })
}

const stream = bunyanFirehose.createStream(config)

stream.on('error', (err) => console.error(`Firehose log error: `, err))

const loggerConfig = {
  name:        'Firehose Demo App',
  level:       'info',
  serializers: bunyan.stdSerializers,
  streams: [
    { stream: process.stdout, level: 'info' },
    { stream, type: 'raw' }
  ]
}

const msg  = 'Well hello there, firehose!'
const data = { demo: 'data' }

logger.info({ msg, data })
logger.info('Simple strings are converted to objects in bunyan')
logger.warn('This is a warning')

Releases

No releases published

Packages

No packages published