bunyan-rethinkdb

2.0.1 • Public • Published

bunyan-rethinkdb

GratiPay Downloads Version

Bunyan logger that sends data to RethinkDB.

Installation

bunyan-rethinkdb expects that you have already installed rethinkdb.

npm instal --save-dev bunyan-rethinkdb

Usage

bunyan-rethinkdb expects the follow:

  • You have already created bunyan_logs (or another table configured via tableName option)
  • You have already opened your connection. If the connection is closed, bunyan-rethinkdb will try to send the data when connection is (re)opened.
import bunyan from 'bunyan';
import BunyanToRethinkDB from 'bunyan-rethinkdb';
import r from 'rethinkdb';
 
// open RethinkDB connection first
// const connection = ...
 
const logger = bunyan.createLogger({
  name: 'rethinkdb',
  streams: [
    { stream: process.stdout },
    { stream: new BunyanToRethinkDB(r, connection) }
  ]
});
 
logger.info({ foo: 1 }, 'Hello world!');

Options

Constructor takes an optional third value with options: new BunyanToRethinkDB(r, connection, options)

bufferLength

Whenever buffer reaches number of log messages specified by bufferLength, all messages will be sent to RethinkDB. Default value is 1.

bufferTimeout

Buffer will be sent to RethinkDB every bufferTimeout milliseconds. Zero disables this feature. Default value is 0.

tableName

RethinkDB table name. Default value is bunyan_logs.

License

ISC

Package Sidebar

Install

npm i bunyan-rethinkdb

Weekly Downloads

1

Version

2.0.1

License

ISC

Last publish

Collaborators

  • alexgorbatchev