winston-beanstalkd
v0.1.4
Published
An Beanstalkd transport for winston
Downloads
8
Maintainers
Readme
winston-beanstalkd
A Beanstalkd transport for winston.
Motivation
To enable a log-based work queue compatible with existing logging mechanisms.
Usage
var winston = require('winston');
//
// Requiring `winston-beanstalkd` will expose
// `winston.transports.Beanstalkd`
//
require('winston-beanstalkd').Beanstalkd;
winston.add(winston.transports.Beanstalkd, options);
The Beanstalkd transport takes the following options. 'host' is required:
- silent: Boolean flag indicating whether to suppress output, defaults to false.
- host: The host running Beanstalkd, defaults to localhost.
- port: The port on the host that Beanstalkd is running on, defaults to
- tube: The name of the tube you want to log to, defaults to 'winston.log'. See beanstalkd FAQ.
- delay: See the beanstalkd FAQ.
- priority: See the beanstalkd FAQ.
- ttr: See the beanstalkd FAQ.
- levelFilter: Whether to append the logging level to the tube name to filter on log level.
- transformMessage: A custom function for transforming logged objects to a queue string, defaults to JSON.stringify().
Installation
Installing npm (node package manager)
$ curl http://npmjs.org/install.sh | sh
Installing winston-beanstalkd
$ npm install winston
$ npm install winston-beanstalkd
Usage
See the examples for a logger and a watcher.
In one console, start the watcher:
$ node examples/watch.js
Watching for logs on winston.log...
In another console, run the logger:
$ node examples/logger.js
info: Beanstalkd log event!
warn: This is a warning!
error: This is an error! code=505, anything=This is metadata
help: Log number 0
help: Log number 1
help: Log number 2
help: Log number 3
help: Log number 4
log put to winston.log { level: 'info',
text: ' Beanstalkd log event!',
meta: undefined }
closing...
log put to winston.log { level: 'warn', text: ' This is a warning!', meta: undefined }
closing...
log put to winston.log { level: 'error',
text: ' This is an error!',
meta: { code: '505', anything: 'This is metadata' } }
closing...
log put to winston.log { level: 'help', text: ' Log number 0', meta: undefined }
closing...
log put to winston.log { level: 'help', text: ' Log number 1', meta: undefined }
closing...
log put to winston.log { level: 'help', text: ' Log number 2', meta: undefined }
closing...
log put to winston.log { level: 'help', text: ' Log number 3', meta: undefined }
closing...
log put to winston.log { level: 'help', text: ' Log number 4', meta: undefined }
closing...
Return to the watcher console and see the output from processing the log entries:
$ node examples/watch.js
Watching for logs on winston.log...
received log: { id: '198',
data: '{"level":"info","text":" Beanstalkd log event!"}' }
processing log entry...
processed: true { id: '198',
data: '{"level":"info","text":" Beanstalkd log event!"}' }
deleted { id: '198',
data: '{"level":"info","text":" Beanstalkd log event!"}' }
[ 'DELETED' ]
Watching for logs on winston.log...
received log: { id: '199',
data: '{"level":"warn","text":" This is a warning!"}' }
processing log entry...
processed: true { id: '199',
data: '{"level":"warn","text":" This is a warning!"}' }
deleted { id: '199',
data: '{"level":"warn","text":" This is a warning!"}' }
[ 'DELETED' ]
Watching for logs on winston.log...
received log: { id: '200',
data: '{"level":"error","text":" This is an error!","meta":{"code":"505","anything":"This is metadata"}}' }
processing log entry...
processed: true { id: '200',
data: '{"level":"error","text":" This is an error!","meta":{"code":"505","anything":"This is metadata"}}' }
deleted { id: '200',
data: '{"level":"error","text":" This is an error!","meta":{"code":"505","anything":"This is metadata"}}' }
[ 'DELETED' ]
Watching for logs on winston.log...
received log: { id: '201', data: '{"level":"help","text":" Log number 0"}' }
processing log entry...
processed: true { id: '201', data: '{"level":"help","text":" Log number 0"}' }
deleted { id: '201', data: '{"level":"help","text":" Log number 0"}' }
[ 'DELETED' ]
Watching for logs on winston.log...
received log: { id: '202', data: '{"level":"help","text":" Log number 1"}' }
processing log entry...
processed: true { id: '202', data: '{"level":"help","text":" Log number 1"}' }
deleted { id: '202', data: '{"level":"help","text":" Log number 1"}' }
[ 'DELETED' ]
Watching for logs on winston.log...
received log: { id: '203', data: '{"level":"help","text":" Log number 2"}' }
processing log entry...
processed: true { id: '203', data: '{"level":"help","text":" Log number 2"}' }
deleted { id: '203', data: '{"level":"help","text":" Log number 2"}' }
[ 'DELETED' ]
Watching for logs on winston.log...
received log: { id: '204', data: '{"level":"help","text":" Log number 3"}' }
processing log entry...
processed: true { id: '204', data: '{"level":"help","text":" Log number 3"}' }
deleted { id: '204', data: '{"level":"help","text":" Log number 3"}' }
[ 'DELETED' ]
Watching for logs on winston.log...
received log: { id: '205', data: '{"level":"help","text":" Log number 4"}' }
processing log entry...
processed: true { id: '205', data: '{"level":"help","text":" Log number 4"}' }
deleted { id: '205', data: '{"level":"help","text":" Log number 4"}' }
[ 'DELETED' ]
Watching for logs on winston.log...
process callback
process callback
process callback
process callback
process callback
process callback
process callback
process callback