winston-rethinkdb
v1.0.0
Published
A RethinkDB transport for winston
Downloads
4
Readme
winston-rethinkdb
A RethinkDB transport for winston.
Uses rethinkdbdash for it's client driver, and supports querying and streaming.
Usage
var winston = require('winston')
// Requiring 'winston-rethinkdb' will expose `winston.transports.RethinkDB`
require('winston-rethinkdb').RethinkDB
winston.add(winston.transports.RethinkDB, options)
The RethinkDB transport takes the following options:
- name: Transport instance identifier when creating multiple RethinkDB transports. Optional, defaults to 'rethinkdb'.
- level: Level of messages that should be recorded. Optional, defaults to 'info'.
- label: Label to add to log records. Optional.
- silent: Set to true to suppress recording of log messages.
- storeHost: Set to true to add os.hostname() to log records.
- db: Name of database to use for saving logs. Optional, defaults to 'test'.
- table: Name of table to use for saving logs. Optional, defaults to 'log'.
- options: rethinkdbdash options or function that returns pre-configured reql.
Connecting
If options.options is an object, it is passed directly to rethinkdbdash or nothing is passed (connecting to localhost
:28015) if options.options is undefined.
A function can be passed instead of an object, it will be called and expects a ReQL term object to be returned.
options.options = {
servers: [
{host: '192.168.0.100', port: 28015},
{host: '192.168.0.101', port: 28015},
{host: '192.168.0.102', port: 28015},
],
buffer: 300,
max: 3000
}
winston.add(winston.transports.RethinkDB, options)
Could also be written as follows, if you intend to use r
for other modules (ie. session-rethinkdb) or just elsewhere in your application to avoid multiple connection pool configurations.
var r = require('rethinkdb')({
servers: [
{host: '192.168.0.100', port: 28015},
{host: '192.168.0.101', port: 28015},
{host: '192.168.0.102', port: 28015},
],
buffer: 300,
max: 3000
})
options.options = function () { return r }
winston.add(winston.transports.RethinkDB, options)
unit test plan
I have not had a chance to write automated tests, but have identified the following test cases that I intend to get tests written for soon.
- constructor options
- initialization when db and table exist
- initialization when db exists, table does not
- initialization when neither db nor table exist
- queue log attempts until transport is ready
- circular references in meta data when logging
- too deeply nested meta data
- connection pool connectivity issues
- query loggly options
- query attempts before transport is ready
- stream attempts before transport is ready
- stream options
- stream disconnection
- attempting log, query or stream after closed