logstash-redis
Uber simple Logstash logging using Redis
Node version: 0.8.0 required
Installation
npm install logstash-redis
Usage
The simple way:
var logstashRedis = ; var logger = logstashRedis; logger; logger;
Using a base object for each log:
var logstashRedis = ; var baseObject = type: 'someValue' env: "prod-1234"; var logger = logstashRedis; logger; logger;
Using a base function for each log:
var logstashRedis = ; var { return type: 'someValue' meta: timestamp: host: hostname ;}; var logger = logstashRedis; logger; logger;
API
createLogger(host, port, key, [base])
Initiate a Redis connection. When the base
parameter is specified, it is used as a base for each log object. It can be an object or a function.
logger.log(data, [callback])
Logs some data asynchronously. Data is a valid javascript object. If a base object or function had been provided during initialisation, data will extend it.
logger.onError(fn)
Subscribes a function fn
to the error event. When the error will happen fn
will be executed with some error details as parameter.
logger.close([callback]);
Cleanly closes the Redis connection (all replies will be parsed).
The NullLogger
It does exactly nothing. Good for testing.
var logstashRedis = ; var logger = logstashRedis; logger;// does nothing logger;// does nothing
Tests
npm test
License
MIT