2.0.1 • Published 9 years ago
bunyan-rethinkdb v2.0.1
bunyan-rethinkdb
Bunyan logger that sends data to RethinkDB.
Installation
bunyan-rethinkdb expects that you have already installed rethinkdb.
npm instal --save-dev bunyan-rethinkdbUsage
bunyan-rethinkdb expects the follow:
- You have already created
bunyan_logs(or another table configured viatableNameoption) - You have already opened your connection. If the connection is closed,
bunyan-rethinkdbwill 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