Skip to content

Commit

Permalink
add transport error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
objt-ev committed Jan 17, 2023
1 parent 311e618 commit 077c4df
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions log-elk-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function (RED) {
var user = this.credentials.username || '';
var pass = this.credentials.password || '';
if (url) {
transports.push(new winstonElasticSearch.ElasticsearchTransport({
const esTransport = new winstonElasticSearch.ElasticsearchTransport({
clientOpts: {
node: url,
auth: {
Expand All @@ -40,7 +40,13 @@ module.exports = function (RED) {
}
},
transformer: transformer
}));
})

transports.push(esTransport);

esTransport.on('error', (error) => {
console.error('Error in esTransport caught', error);
});
}
}

Expand Down Expand Up @@ -83,6 +89,10 @@ module.exports = function (RED) {
transports: transports
});

logger.on('error', (error) => {
console.error('Error in logger caught', error);
});

this.debug("log-elk logger created");
}

Expand Down

0 comments on commit 077c4df

Please sign in to comment.