bunyan-cassandra
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -17,2 +17,4 @@ 'use strict'; | ||
function BunyanCassandra(opts) { | ||
opts = opts || {}; | ||
this.hosts = opts.hosts || ['localhost']; | ||
@@ -25,2 +27,3 @@ this.keyspace = opts.keyspace || 'logs'; | ||
this.callback = opts.callback; | ||
this.transform = opts.transform; | ||
@@ -41,2 +44,6 @@ this.client = new cql.Client({ | ||
BunyanCassandra.prototype.write = function (row) { | ||
if (isFunction(this.transform)) { | ||
row = this.transform(row); | ||
} | ||
var ctx = this; | ||
@@ -43,0 +50,0 @@ var argsValues = this.args.map(function (arg) { |
{ | ||
"name": "bunyan-cassandra", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Cassandra bunyan stream", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -63,2 +63,5 @@ bunyan-cassandra | ||
// or catch possible Cassandra errors | ||
}, | ||
transform: function (log) { | ||
// add/remove/edit log object | ||
} | ||
@@ -149,1 +152,11 @@ }) | ||
**default** ``undefined`` | ||
#### transform | ||
Each time when new log is received, log will be passed as argument to ``transform`` function, so you will have opportunity to modify raw log data, for example add or remove some fields from log. | ||
``` | ||
transform: function (row) { | ||
// let we say we want date with specific format | ||
row.date = moment(row.time).format('YYYY-MM-DD'); | ||
return row; | ||
} | ||
``` |
5760
50
160