@5minds/node-red-contrib-processcube-elasticsearch 0.3.1-add-update-cycle-49119c-m3ra2qmc → 0.3.1-add-update-cycle-b6ecd7-m3sggsnp
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/elastic-search-logger.js +17 -4
- package/package.json +1 -1
package/elastic-search-logger.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
module.exports = function (RED) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
let lock = false;
|
|
5
|
+
|
|
4
6
|
function LogElasticLoggerNode(config) {
|
|
5
7
|
let winston = require('winston');
|
|
6
8
|
let winstonElasticSearch = require('winston-elasticsearch');
|
|
@@ -15,6 +17,8 @@ module.exports = function (RED) {
|
|
|
15
17
|
let url, user, password, index;
|
|
16
18
|
|
|
17
19
|
function refresh() {
|
|
20
|
+
if (lock) return;
|
|
21
|
+
|
|
18
22
|
// Elastic settings
|
|
19
23
|
let newUrl = RED.util.evaluateNodeProperty(config.url, config.urlType, this);
|
|
20
24
|
if (newUrl == '') {
|
|
@@ -44,8 +48,6 @@ module.exports = function (RED) {
|
|
|
44
48
|
return;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
if (this.logger) this.logger.close();
|
|
48
|
-
|
|
49
51
|
url = newUrl;
|
|
50
52
|
user = newUser;
|
|
51
53
|
password = newPassword;
|
|
@@ -85,13 +87,24 @@ module.exports = function (RED) {
|
|
|
85
87
|
Debug: 3,
|
|
86
88
|
},
|
|
87
89
|
};
|
|
88
|
-
|
|
90
|
+
|
|
91
|
+
const newLogger = new winston.createLogger({
|
|
89
92
|
exitOnError: false,
|
|
90
93
|
level: 'Debug',
|
|
91
94
|
levels: logLevels.levels,
|
|
92
95
|
transports: transports,
|
|
93
96
|
});
|
|
94
97
|
|
|
98
|
+
lock = true;
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
if (this.logger) this.logger.close();
|
|
102
|
+
|
|
103
|
+
this.logger = newLogger;
|
|
104
|
+
} finally {
|
|
105
|
+
lock = false;
|
|
106
|
+
}
|
|
107
|
+
|
|
95
108
|
this.debug('elastic-search logger created');
|
|
96
109
|
}
|
|
97
110
|
|
|
@@ -140,6 +153,6 @@ module.exports = function (RED) {
|
|
|
140
153
|
});
|
|
141
154
|
|
|
142
155
|
LogElasticLoggerNode.prototype.addToLog = function addTolog(loglevel, msg) {
|
|
143
|
-
this.logger.log(loglevel, msg.payload.message, msg.payload.meta);
|
|
156
|
+
if (!lock && this.logger) this.logger.log(loglevel, msg.payload.message, msg.payload.meta);
|
|
144
157
|
};
|
|
145
158
|
};
|
package/package.json
CHANGED