Skip to content

Commit

Permalink
Bump to 0.0.6 and fix the default error listener removal
Browse files Browse the repository at this point in the history
  • Loading branch information
hmalphettes committed Apr 22, 2014
1 parent 87906c3 commit 165e655
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/elasticsearch-client.js
Expand Up @@ -22,7 +22,7 @@ ElasticSearchClient.prototype = Object.create(EventEmitter.prototype);

var numberOfErrorsReported = 3;
// default error listener will report in the console 3 times
var errorInsertDefaultListener = function(err) {
var errorDefaultListener = function(err) {
if (numberOfErrorsReported) {
console.log('Error %d occured while posting log to ES:', err);
numberOfErrorsReported--;
Expand All @@ -31,12 +31,12 @@ var errorInsertDefaultListener = function(err) {

ElasticSearchClient.prototype.init = function() {
// node's event emitter will crash if no error listeners were registered
this.on('error', errorInsertDefaultListener);
this.on('error', errorDefaultListener);
var self = this;
this.on('newListener', function(eventName, listener) {
if (eventName === 'error.insert' && listener !== errorInsertDefaultListener) {
if (eventName === 'error' && listener !== errorDefaultListener) {
// Remove the default listener if it had been registered previously.
self.removeListener(eventName, errorInsertDefaultListener);
self.removeListener(eventName, errorDefaultListener);
}
});
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "log4js-elasticsearch",
"version": "0.0.5",
"version": "0.0.6",
"description": "log4js appender for node that targets elasticsearch.\nCompatible with logstash's elasticsearch_http output; Viewable with Kibana.",
"main": "lib/log4js-elasticsearch.js",
"scripts": {
Expand Down

0 comments on commit 165e655

Please sign in to comment.