From 9a969903a2e603ef6e962ba6e05d9932e7547527 Mon Sep 17 00:00:00 2001 From: kclark Date: Thu, 16 Apr 2020 07:56:29 -0400 Subject: [PATCH] Create graygelf in constructor once vs on every call to eventHandle --- lib/plugins/output/gelfout.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/plugins/output/gelfout.js b/lib/plugins/output/gelfout.js index d32a823e..4be81f1f 100644 --- a/lib/plugins/output/gelfout.js +++ b/lib/plugins/output/gelfout.js @@ -8,15 +8,20 @@ function OutputGELF (config, eventEmitter) { this.compression = config.compression || 'deflate' this.chunkSize = config.chunkSize || 1024 this.eventEmitter = eventEmitter + this.log = graygelf({ + host: this.config.host, + port: this.config.port, + compressType: this.compression, + chunkSize: this.chunkSize + }) } OutputGELF.prototype.eventHandler = function (data, context) { if (this.config.debug) { console.log('context ' + JSON.stringify(context)) } - var log = graygelf({host: this.config.host, port: this.config.port, compressType: this.compression, chunkSize: this.chunkSize}) var rawMessage = this.mapData(data, context) - log.raw(rawMessage) + this.log.raw(rawMessage) } OutputGELF.prototype.mapData = function (data, context) {