From 3dd957ec561bd0e83be8990ff043329fd661237b Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Mon, 18 Jun 2018 16:47:16 +0900 Subject: [PATCH 1/3] Define properties to log when _status is changed Signed-off-by: Kenji Okimoto --- lib/sender.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/sender.js b/lib/sender.js index 2934b2c..fb409eb 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -53,7 +53,18 @@ function FluentSender(tag_prefix, options) { }; this.sharedKeySalt = crypto.randomBytes(16).toString('hex'); // helo, pingpong, established - this._status = null; + Object.defineProperties(this, { + '_status': { + get: function() { + return this.__status; + }, + set: function(newStatus) { + this.internalLogger.log({oldStatus: this.__status, newStatus: newStatus}); + this.__status = newStatus; + } + } + }); + this.__status = null; this._connecting = false; } From 1e6ac6f4607628462fcb348a56f59dd7282f78c7 Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Mon, 18 Jun 2018 17:20:09 +0900 Subject: [PATCH 2/3] Emit `reconnect` event after reconnection Signed-off-by: Kenji Okimoto --- lib/sender.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sender.js b/lib/sender.js index fb409eb..bd93326 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -462,6 +462,7 @@ FluentSender.prototype._setupErrorHandler = function _setupErrorHandler(callback this.internalLogger.info('Fluentd is reconnecting...'); this._connect(() => { this.internalLogger.info('Fluentd reconnection finished!!'); + this._handleEvent('reconnect'); }); }, this.reconnectInterval); callback && callback(timeoutId); From f52e4fc11d3869c380c1ca14d565a9f99b5657ca Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Mon, 18 Jun 2018 17:59:46 +0900 Subject: [PATCH 3/3] Use log level info to log status Signed-off-by: Kenji Okimoto --- lib/sender.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sender.js b/lib/sender.js index bd93326..2a1a49e 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -59,7 +59,7 @@ function FluentSender(tag_prefix, options) { return this.__status; }, set: function(newStatus) { - this.internalLogger.log({oldStatus: this.__status, newStatus: newStatus}); + this.internalLogger.info({oldStatus: this.__status, newStatus: newStatus}); this.__status = newStatus; } }