Bunyan logger that sends data to RethinkDB.
bunyan-rethinkdb
expects that you have already installed rethinkdb
.
npm instal --save-dev bunyan-rethinkdb
bunyan-rethinkdb
expects the follow:
- You have already created
bunyan_logs
(or another table configured viatableName
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!');
Constructor takes an optional third value with options: new BunyanToRethinkDB(r, connection, options)
Whenever buffer reaches number of log messages specified by bufferLength
, all messages will be sent to RethinkDB. Default value is 1
.
Buffer will be sent to RethinkDB every bufferTimeout
milliseconds. Zero disables this feature. Default value is 0
.
RethinkDB table name. Default value is bunyan_logs
.
ISC