kuzzle 2.44.0 → 2.45.0

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.
Files changed (40) hide show
  1. package/lib/api/controllers/adminController.js +2 -1
  2. package/lib/api/controllers/authController.d.ts +1 -0
  3. package/lib/api/controllers/authController.js +2 -1
  4. package/lib/api/controllers/securityController.js +22 -20
  5. package/lib/api/funnel.js +30 -10
  6. package/lib/cluster/command.js +3 -2
  7. package/lib/cluster/idCardHandler.d.ts +1 -0
  8. package/lib/cluster/idCardHandler.js +2 -1
  9. package/lib/cluster/node.js +18 -19
  10. package/lib/cluster/subscriber.js +5 -3
  11. package/lib/core/backend/backend.d.ts +3 -2
  12. package/lib/core/backend/backend.js +1 -1
  13. package/lib/core/cache/cacheEngine.js +3 -1
  14. package/lib/core/network/accessLogger.js +3 -2
  15. package/lib/core/network/entryPoint.js +7 -7
  16. package/lib/core/network/protocols/httpwsProtocol.js +7 -7
  17. package/lib/core/network/protocols/mqttProtocol.js +3 -2
  18. package/lib/core/network/router.js +4 -3
  19. package/lib/core/plugin/pluginsManager.js +13 -5
  20. package/lib/core/realtime/hotelClerk.d.ts +1 -0
  21. package/lib/core/realtime/hotelClerk.js +4 -3
  22. package/lib/core/realtime/notifier.js +2 -1
  23. package/lib/core/security/roleRepository.js +3 -2
  24. package/lib/core/security/securityLoader.js +5 -7
  25. package/lib/core/shared/store.d.ts +1 -0
  26. package/lib/core/shared/store.js +2 -1
  27. package/lib/core/statistics/statistics.js +3 -1
  28. package/lib/core/storage/storageEngine.js +6 -1
  29. package/lib/core/validation/validation.js +6 -5
  30. package/lib/kuzzle/dumpGenerator.js +17 -16
  31. package/lib/kuzzle/internalIndexHandler.js +3 -1
  32. package/lib/kuzzle/kuzzle.js +0 -1
  33. package/lib/service/cache/redis.js +4 -0
  34. package/lib/service/storage/7/elasticsearch.d.ts +1 -0
  35. package/lib/service/storage/7/elasticsearch.js +5 -4
  36. package/lib/service/storage/8/elasticsearch.d.ts +1 -0
  37. package/lib/service/storage/8/elasticsearch.js +5 -4
  38. package/lib/service/storage/Elasticsearch.d.ts +1 -0
  39. package/lib/service/storage/Elasticsearch.js +1 -1
  40. package/package.json +1 -1
@@ -120,6 +120,8 @@ class HttpWsProtocol extends Protocol {
120
120
 
121
121
  // Map<string, uWS.WebSocket>
122
122
  this.socketByConnectionId = new Map();
123
+
124
+ this.logger = global.kuzzle.log.child("core:network:protocols:httpws");
123
125
  }
124
126
 
125
127
  async init(entrypoint) {
@@ -318,7 +320,7 @@ class HttpWsProtocol extends Protocol {
318
320
  // This hack is only here to indicate that uWebSockets killed the connection early
319
321
  // because the received payload exceeded the configured threshold.
320
322
  if (code === 1006 && reason.startsWith("Received too big message")) {
321
- global.kuzzle.log.error(
323
+ this.logger.error(
322
324
  `[${connection.id}] connection closed: payload exceeded the threshold`,
323
325
  );
324
326
  }
@@ -1146,7 +1148,7 @@ class HttpWsProtocol extends Protocol {
1146
1148
  const cfg = this.config.websocket;
1147
1149
 
1148
1150
  if (cfg === undefined) {
1149
- global.kuzzle.log.warn(
1151
+ this.logger.warn(
1150
1152
  "[websocket] no configuration found for websocket: disabling it",
1151
1153
  );
1152
1154
  return { enabled: false };
@@ -1157,7 +1159,7 @@ class HttpWsProtocol extends Protocol {
1157
1159
 
1158
1160
  if (idleTimeout === 0 || idleTimeout < 1000) {
1159
1161
  idleTimeout = DEFAULT_IDLE_TIMEOUT;
1160
- global.kuzzle.log.warn(
1162
+ this.logger.warn(
1161
1163
  `[websocket] The "idleTimeout" parameter can neither be deactivated or be set with a value lower than 1000. Defaulted to ${DEFAULT_IDLE_TIMEOUT}.`,
1162
1164
  );
1163
1165
  }
@@ -1168,7 +1170,7 @@ class HttpWsProtocol extends Protocol {
1168
1170
  * @deprecated -- to be removed in the next major version
1169
1171
  */
1170
1172
  if (cfg.heartbeat) {
1171
- global.kuzzle.log.warn(
1173
+ this.logger.warn(
1172
1174
  '[websocket] The "heartbeat" parameter has been deprecated and is now ignored. The "idleTimeout" parameter should now be configured instead.',
1173
1175
  );
1174
1176
  }
@@ -1190,9 +1192,7 @@ class HttpWsProtocol extends Protocol {
1190
1192
  const cfg = this.config.http;
1191
1193
 
1192
1194
  if (cfg === undefined) {
1193
- global.kuzzle.log.warn(
1194
- "[http] no configuration found for http: disabling it",
1195
- );
1195
+ this.logger.warn("[http] no configuration found for http: disabling it");
1196
1196
  return { enabled: false };
1197
1197
  }
1198
1198
 
@@ -45,11 +45,12 @@ class MqttProtocol extends Protocol {
45
45
 
46
46
  this.connections = new Map();
47
47
  this.connectionsById = new Map();
48
+ this.logger = global.kuzzle.log.child("core:network:protocols:mqtt");
48
49
 
49
50
  // needs to be bound to this object's context
50
51
  this.publishCallback = function pubcb(error) {
51
52
  if (error) {
52
- global.kuzzle.info(`[MQTT] Publishing message failed: ${error}`);
53
+ this.logger.info(`[MQTT] Publishing message failed: ${error}`);
53
54
  }
54
55
  };
55
56
  }
@@ -201,7 +202,7 @@ class MqttProtocol extends Protocol {
201
202
  client.id,
202
203
  packet,
203
204
  );
204
- global.kuzzle.log.error(
205
+ this.logger.error(
205
206
  `[MQTT] Received a packet from an unregistered client: ${client.id}`,
206
207
  );
207
208
  return;
@@ -36,6 +36,7 @@ class Router {
36
36
  constructor() {
37
37
  this.connections = new Map();
38
38
  this.http = new HttpRouter();
39
+ this.logger = global.kuzzle.log.child("core:network:router");
39
40
  }
40
41
 
41
42
  /**
@@ -45,7 +46,7 @@ class Router {
45
46
  */
46
47
  newConnection(requestContext) {
47
48
  if (!requestContext.connection.id || !requestContext.connection.protocol) {
48
- global.kuzzle.log.error(
49
+ this.logger.error(
49
50
  kerror.get(
50
51
  "protocol",
51
52
  "runtime",
@@ -68,7 +69,7 @@ class Router {
68
69
  const connId = requestContext.connection.id;
69
70
 
70
71
  if (!connId || !requestContext.connection.protocol) {
71
- global.kuzzle.log.error(
72
+ this.logger.error(
72
73
  kerror.get(
73
74
  "protocol",
74
75
  "runtime",
@@ -80,7 +81,7 @@ class Router {
80
81
  }
81
82
 
82
83
  if (!this.connections.has(connId)) {
83
- global.kuzzle.log.error(
84
+ this.logger.error(
84
85
  kerror.get(
85
86
  "protocol",
86
87
  "runtime",
@@ -90,9 +90,11 @@ class PluginsManager {
90
90
 
91
91
  this.config = global.kuzzle.config.plugins;
92
92
 
93
+ this.logger = global.kuzzle.log.child("core:plugin:pluginsManager");
94
+
93
95
  // @deprecated - Warn about the pipeTimeout configuration being obsolete
94
96
  if (this.config.common.pipeTimeout) {
95
- global.kuzzle.log.warn(
97
+ this.logger.warn(
96
98
  'The configuration "plugins.common.pipeTimeout" has been deprecated and is now unused. It can be safely removed from configuration files',
97
99
  );
98
100
  }
@@ -208,13 +210,13 @@ class PluginsManager {
208
210
  this._plugins = new Map([...this.loadPlugins(plugins), ...this._plugins]);
209
211
 
210
212
  global.kuzzle.on("plugin:hook:loop-error", ({ error, pluginName }) => {
211
- global.kuzzle.log.error(
213
+ this.logger.error(
212
214
  `[${pluginName}] Infinite loop detected on event "hook:onError": ${error}`,
213
215
  );
214
216
  });
215
217
 
216
218
  global.kuzzle.on("hook:onError", ({ error, event, pluginName }) => {
217
- global.kuzzle.log.error(
219
+ this.logger.error(
218
220
  `[${pluginName}] Error executing hook on "${event}": ${error}${error.stack}`,
219
221
  );
220
222
  });
@@ -228,7 +230,7 @@ class PluginsManager {
228
230
  this.config.common.failsafeMode &&
229
231
  !CORE_PLUGINS.includes(plugin.name)
230
232
  ) {
231
- global.kuzzle.log.info(
233
+ this.logger.info(
232
234
  `Failsafe mode activated, skipping plugin "${plugin.name}"`,
233
235
  );
234
236
  continue;
@@ -311,6 +313,12 @@ class PluginsManager {
311
313
 
312
314
  await Promise.all(loadPlugins);
313
315
 
316
+ this.logger.info(
317
+ `[✔] Successfully loaded ${
318
+ this.loadedPlugins.length
319
+ } plugins: ${this.loadedPlugins.join(", ")}`,
320
+ );
321
+
314
322
  return defaultImports;
315
323
  }
316
324
 
@@ -489,7 +497,7 @@ class PluginsManager {
489
497
  const elapsed = Date.now() - now;
490
498
 
491
499
  if (elapsed > warnDelay) {
492
- global.kuzzle.log.warn(
500
+ this.logger.warn(
493
501
  `${plugin.logPrefix} pipe for event '${event}' is slow (${elapsed}ms)`,
494
502
  );
495
503
  }
@@ -46,6 +46,7 @@ export declare class HotelClerk {
46
46
  * Shortcut to the Koncorde instance on the global object.
47
47
  */
48
48
  private koncorde;
49
+ private readonly logger;
49
50
  constructor(realtimeModule: any);
50
51
  /**
51
52
  * Registers the ask events.
@@ -100,6 +100,7 @@ class HotelClerk {
100
100
  * Map<connectionId, ConnectionRooms>
101
101
  */
102
102
  this.subscriptions = new Map();
103
+ this.logger = global.kuzzle.log.child("core:realtime:hotelClerk");
103
104
  this.module = realtimeModule;
104
105
  this.koncorde = global.kuzzle.koncorde;
105
106
  }
@@ -172,7 +173,7 @@ class HotelClerk {
172
173
  * Clear subscriptions when a connection is dropped
173
174
  */
174
175
  global.kuzzle.on("connection:remove", (connection) => {
175
- this.removeConnection(connection.id).catch((err) => global.kuzzle.log.info(err));
176
+ this.removeConnection(connection.id).catch((err) => this.logger.info(err));
176
177
  });
177
178
  }
178
179
  /**
@@ -339,7 +340,7 @@ class HotelClerk {
339
340
  // No need to raise an error if the connection does not have room subscriptions
340
341
  return;
341
342
  }
342
- await bluebird_1.default.map(connectionRooms.roomIds, (roomId) => this.unsubscribe(connectionId, roomId, notify).catch((error) => global.kuzzle.log.error(error)));
343
+ await bluebird_1.default.map(connectionRooms.roomIds, (roomId) => this.unsubscribe(connectionId, roomId, notify).catch((error) => this.logger.error(error)));
343
344
  }
344
345
  /**
345
346
  * Clear all connections made to this node:
@@ -421,7 +422,7 @@ class HotelClerk {
421
422
  }
422
423
  const room = this.rooms.get(roomId);
423
424
  if (!room) {
424
- global.kuzzle.log.error(`Cannot remove room "${roomId}": room not found`);
425
+ this.logger.error(`Cannot remove room "${roomId}": room not found`);
425
426
  throw realtimeError.get("room_not_found", roomId);
426
427
  }
427
428
  for (const channel of Object.keys(room.channels)) {
@@ -56,6 +56,7 @@ class NotifierController {
56
56
  constructor(realtimeModule) {
57
57
  this.module = realtimeModule;
58
58
  this.ttl = global.kuzzle.config.limits.subscriptionDocumentTTL;
59
+ this.logger = global.kuzzle.log.child("core:realtime:notifier");
59
60
  }
60
61
 
61
62
  async init() {
@@ -430,7 +431,7 @@ class NotifierController {
430
431
  payload: updatedInfo.notification,
431
432
  });
432
433
  } catch (error) {
433
- global.kuzzle.log.error(error);
434
+ this.logger.error(error);
434
435
  }
435
436
  }
436
437
 
@@ -52,6 +52,7 @@ class RoleRepository extends ObjectRepository {
52
52
  this.collection = "roles";
53
53
  this.ObjectConstructor = Role;
54
54
  this.roles = new Map();
55
+ this.logger = global.kuzzle.log.child("core:security:roleRepository");
55
56
  }
56
57
 
57
58
  init() {
@@ -438,7 +439,7 @@ class RoleRepository extends ObjectRepository {
438
439
  // then we need to display non-existing controllers with the sanity check
439
440
  // made after plugins controllers loading.
440
441
  if (global.kuzzle.state === kuzzleStateEnum.RUNNING || forceWarn) {
441
- global.kuzzle.log.warn(
442
+ this.logger.warn(
442
443
  `The role "${role._id}" gives access to the non-existing controller "${roleController}".`,
443
444
  );
444
445
  }
@@ -461,7 +462,7 @@ class RoleRepository extends ObjectRepository {
461
462
 
462
463
  // see the other comment
463
464
  if (global.kuzzle.state === kuzzleStateEnum.RUNNING || forceWarn) {
464
- global.kuzzle.log.warn(
465
+ this.logger.warn(
465
466
  `The role "${role._id}" gives access to the non-existing action "${action}" for the controller "${roleController}".`,
466
467
  );
467
468
  }
@@ -32,7 +32,9 @@ const kerror = require("../../kerror");
32
32
  * @class SecurityLoader
33
33
  */
34
34
  class SecurityLoader {
35
- constructor() {}
35
+ constructor() {
36
+ this.logger = global.kuzzle.log.child("core:security:loader");
37
+ }
36
38
 
37
39
  async init() {
38
40
  /**
@@ -134,9 +136,7 @@ class SecurityLoader {
134
136
  throw kerror.get("security", "user", "prevent_overwrite");
135
137
  } else if (onExistingUsers === "skip") {
136
138
  if (warning) {
137
- global.kuzzle.log.info(
138
- `Users skipped during import: ${existingUserIds}`,
139
- );
139
+ this.logger.info(`Users skipped during import: ${existingUserIds}`);
140
140
  }
141
141
  return Object.entries(users).reduce((memo, [userId, content]) => {
142
142
  if (!existingUserIds.includes(userId)) {
@@ -147,9 +147,7 @@ class SecurityLoader {
147
147
  }, {});
148
148
  } else if (onExistingUsers === "overwrite") {
149
149
  if (warning) {
150
- global.kuzzle.log.info(
151
- `Users overwritten during import: ${existingUserIds}`,
152
- );
150
+ this.logger.info(`Users overwritten during import: ${existingUserIds}`);
153
151
  }
154
152
  const mDeleteUsers = new Request({
155
153
  action: "mDeleteUsers",
@@ -33,6 +33,7 @@ export declare class Store {
33
33
  updateMapping: (...args: any[]) => Promise<any>;
34
34
  protected index: string;
35
35
  protected scope: storeScopeEnum;
36
+ private readonly logger;
36
37
  constructor(index: string, scope: storeScopeEnum);
37
38
  /**
38
39
  * Initialize the index, and creates provided collections
@@ -55,6 +55,7 @@ const mutex_1 = require("../../util/mutex");
55
55
  */
56
56
  class Store {
57
57
  constructor(index, scope) {
58
+ this.logger = global.kuzzle.log.child("core:shared:store");
58
59
  this.index = index;
59
60
  this.scope = scope;
60
61
  const methodsMapping = {
@@ -150,7 +151,7 @@ class Store {
150
151
  if (global.NODE_ENV === "development") {
151
152
  throw kerror.get("storage", "wrong_collection_number_of_shards", collection, this.index, this.scope, "number_of_shards", config.settings.number_of_shards, existingSettings.number_of_shards);
152
153
  }
153
- global.kuzzle.log.warn(`Attempt to recreate an existing collection ${collection} of index ${this.index} of scope ${this.scope} with non matching static setting : number_of_shards at ${config.settings.number_of_shards} while existing one is at ${existingSettings.number_of_shards}`);
154
+ this.logger.warn(`Attempt to recreate an existing collection ${collection} of index ${this.index} of scope ${this.scope} with non matching static setting : number_of_shards at ${config.settings.number_of_shards} while existing one is at ${existingSettings.number_of_shards}`);
154
155
  }
155
156
  return global.kuzzle.ask(`core:storage:${this.scope}:collection:create`, this.index, collection,
156
157
  // @deprecated
@@ -47,6 +47,8 @@ class Statistics {
47
47
  failedRequests: new Map(),
48
48
  ongoingRequests: new Map(),
49
49
  };
50
+
51
+ this.logger = global.kuzzle.log.child("core:statistics");
50
52
  }
51
53
 
52
54
  /**
@@ -339,7 +341,7 @@ class Statistics {
339
341
  try {
340
342
  await this.writeStats();
341
343
  } catch (error) {
342
- global.kuzzle.log.error(`Cannot write stats frame: ${error}`);
344
+ this.logger.error(`Cannot write stats frame: ${error}`);
343
345
  }
344
346
  }, this.interval);
345
347
 
@@ -32,6 +32,11 @@ class StorageEngine {
32
32
 
33
33
  // Storage client for private indexes only
34
34
  this.private = new ClientAdapter(storeScopeEnum.PRIVATE);
35
+ this.logger = global.kuzzle.log.child("core:storage:storageEngine");
36
+
37
+ this.logger.info(
38
+ `[ℹ] Elasticsearch configuration is set to major version : ${global.kuzzle.config.services.storageEngine.majorVersion}`,
39
+ );
35
40
  }
36
41
 
37
42
  /**
@@ -51,7 +56,7 @@ class StorageEngine {
51
56
  }
52
57
  }
53
58
 
54
- global.kuzzle.log.info("[✔] Storage initialized");
59
+ this.logger.info("[✔] Storage initialized");
55
60
  }
56
61
  }
57
62
 
@@ -50,6 +50,7 @@ class Validation {
50
50
  this.koncorde = new Koncorde();
51
51
 
52
52
  this.rawConfiguration = {};
53
+ this.logger = global.kuzzle.log.child("core:validation");
53
54
  }
54
55
 
55
56
  /**
@@ -462,10 +463,10 @@ class Validation {
462
463
  return null;
463
464
  })
464
465
  .catch((error) => {
465
- global.kuzzle.log.error(
466
+ this.logger.error(
466
467
  `Specification for the collection ${collectionName} triggered an error`,
467
468
  );
468
- global.kuzzle.log.error(`Error: ${error.message}`);
469
+ this.logger.error(`Error: ${error.message}`);
469
470
 
470
471
  return null;
471
472
  });
@@ -586,7 +587,7 @@ class Validation {
586
587
 
587
588
  processed.validators = filterId;
588
589
  } catch (e) {
589
- global.kuzzle.log.error(e);
590
+ this.logger.error(e);
590
591
  throw assertionError.getFrom(e, "invalid_filters", e.message);
591
592
  }
592
593
  }
@@ -619,7 +620,7 @@ class Validation {
619
620
 
620
621
  if (result.isValid === false) {
621
622
  errors = _.concat(errors, result.errors);
622
- global.kuzzle.log.error(result.errors.join("\n"));
623
+ this.logger.error(result.errors.join("\n"));
623
624
  } else {
624
625
  const field = result.fieldSpec;
625
626
 
@@ -637,7 +638,7 @@ class Validation {
637
638
  fields[field.depth].push(field);
638
639
  }
639
640
  } catch (error) {
640
- global.kuzzle.log.error(error);
641
+ this.logger.error(error);
641
642
  throwOrStoreError(error, verboseErrors, errors);
642
643
  }
643
644
  }
@@ -36,6 +36,7 @@ const kerror = require("../kerror");
36
36
  class DumpGenerator {
37
37
  constructor() {
38
38
  this._dump = false;
39
+ this.logger = global.kuzzle.log.child("dump:dumpGenerator");
39
40
  }
40
41
 
41
42
  /**
@@ -59,8 +60,8 @@ class DumpGenerator {
59
60
  .substring(0, 200),
60
61
  );
61
62
 
62
- global.kuzzle.log.info("=".repeat(79));
63
- global.kuzzle.log.info(`Generating dump in ${dumpPath}`);
63
+ this.logger.info("=".repeat(79));
64
+ this.logger.info(`Generating dump in ${dumpPath}`);
64
65
  this._cleanUpHistory();
65
66
  try {
66
67
  fs.mkdirSync(dumpPath, { recursive: true });
@@ -69,12 +70,12 @@ class DumpGenerator {
69
70
  ? "Dump directory already exists. Skipping.."
70
71
  : `Unable to create dump folder: ${e.message}`;
71
72
 
72
- global.kuzzle.log.error(message);
73
+ this.logger.error(message);
73
74
  throw new Error(message);
74
75
  }
75
76
 
76
77
  // dump kuzzle information
77
- global.kuzzle.log.info("> dumping kuzzle configuration");
78
+ this.logger.info("> dumping kuzzle configuration");
78
79
  fs.writeFileSync(
79
80
  path.join(dumpPath, "kuzzle.json"),
80
81
  JSON.stringify(
@@ -88,7 +89,7 @@ class DumpGenerator {
88
89
  );
89
90
 
90
91
  // dump plugins configuration
91
- global.kuzzle.log.info("> dumping plugins configuration");
92
+ this.logger.info("> dumping plugins configuration");
92
93
  fs.writeFileSync(
93
94
  path.join(dumpPath, "plugins.json"),
94
95
  JSON.stringify(
@@ -99,7 +100,7 @@ class DumpGenerator {
99
100
  );
100
101
 
101
102
  // dump Node.js configuration
102
- global.kuzzle.log.info("> dumping Node.js configuration");
103
+ this.logger.info("> dumping Node.js configuration");
103
104
  fs.writeFileSync(
104
105
  path.join(dumpPath, "nodejs.json"),
105
106
  JSON.stringify(
@@ -117,7 +118,7 @@ class DumpGenerator {
117
118
  );
118
119
 
119
120
  // dump os configuration
120
- global.kuzzle.log.info("> dumping os configuration");
121
+ this.logger.info("> dumping os configuration");
121
122
  fs.writeFileSync(
122
123
  path.join(dumpPath, "os.json"),
123
124
  JSON.stringify(
@@ -138,7 +139,7 @@ class DumpGenerator {
138
139
  );
139
140
 
140
141
  // core-dump
141
- global.kuzzle.log.info("> generating core-dump");
142
+ this.logger.info("> generating core-dump");
142
143
  dumpme(global.kuzzle.config.dump.gcore || "gcore", `${dumpPath}/core`);
143
144
 
144
145
  // Gzip the core
@@ -158,7 +159,7 @@ class DumpGenerator {
158
159
  try {
159
160
  fs.unlinkSync(corefiles[0]);
160
161
  } catch (e) {
161
- global.kuzzle.log.warn(
162
+ this.logger.warn(
162
163
  `> unable to clean up core file ${corefiles[0]}`,
163
164
  );
164
165
  }
@@ -166,18 +167,18 @@ class DumpGenerator {
166
167
  }),
167
168
  );
168
169
  } else {
169
- global.kuzzle.log.warn("> could not generate dump");
170
+ this.logger.warn("> could not generate dump");
170
171
  }
171
172
  } catch (error) {
172
- global.kuzzle.log.error(error);
173
+ this.logger.error(error);
173
174
  }
174
175
 
175
176
  // copy node binary
176
- global.kuzzle.log.info("> copy node binary");
177
+ this.logger.info("> copy node binary");
177
178
  fs.copyFileSync(process.execPath, path.join(dumpPath, "node"));
178
179
 
179
180
  // dumping Kuzzle's stats
180
- global.kuzzle.log.info("> dumping kuzzle's stats");
181
+ this.logger.info("> dumping kuzzle's stats");
181
182
  const statistics = await global.kuzzle.statistics.getAllStats(
182
183
  new Request({ action: "getAllStats", controller: "statistics" }),
183
184
  );
@@ -187,11 +188,11 @@ class DumpGenerator {
187
188
  JSON.stringify(statistics.hits, null, " ").concat("\n"),
188
189
  );
189
190
 
190
- global.kuzzle.log.info("Done.");
191
- global.kuzzle.log.info(
191
+ this.logger.info("Done.");
192
+ this.logger.info(
192
193
  "[ℹ] You can send the folder to the kuzzle core team at support@kuzzle.io",
193
194
  );
194
- global.kuzzle.log.info("=".repeat(79));
195
+ this.logger.info("=".repeat(79));
195
196
 
196
197
  this._dump = false;
197
198
  return dumpPath;
@@ -92,6 +92,8 @@ class InternalIndexHandler extends Store {
92
92
  this._BOOTSTRAP_DONE_ID = `${this.index}.done`;
93
93
  this._DATAMODEL_VERSION_ID = "internalIndex.dataModelVersion";
94
94
  this._JWT_SECRET_ID = "security.jwt.secret";
95
+
96
+ this.logger = global.kuzzle.log.child("internalIndexHandler");
95
97
  }
96
98
 
97
99
  /**
@@ -219,7 +221,7 @@ class InternalIndexHandler extends Store {
219
221
  );
220
222
  }
221
223
 
222
- global.kuzzle.log.warn(
224
+ this.logger.warn(
223
225
  "[!] Kuzzle is using a generated seed for authentication. This is suitable for development but should NEVER be used in production. See https://docs.kuzzle.io/core/2/guides/getting-started/deploy-your-application/",
224
226
  );
225
227
  }
@@ -165,7 +165,6 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
165
165
  await this.debugger.init();
166
166
  this.pluginsManager.application = application;
167
167
  const pluginImports = await this.pluginsManager.init(options.plugins);
168
- this.log.info(`[✔] Successfully loaded ${this.pluginsManager.loadedPlugins.length} plugins: ${this.pluginsManager.loadedPlugins.join(", ")}`);
169
168
  const imports = lodash_1.default.merge({}, pluginImports, options.import);
170
169
  // Authentification plugins must be loaded before users import to avoid
171
170
  // credentials related error which would prevent Kuzzle from starting
@@ -43,6 +43,10 @@ class Redis extends Service {
43
43
  this.commands = {};
44
44
  this.adapterName = name;
45
45
  this.pingIntervalID = null;
46
+
47
+ this.logger = global.kuzzle.log.child // It means we're in the main Kuzzle process
48
+ ? global.kuzzle.log.child("services:cache:redis")
49
+ : global.kuzzle.log;
46
50
  }
47
51
 
48
52
  /**
@@ -24,6 +24,7 @@ export declare class ES7 {
24
24
  maxScrollDuration: number;
25
25
  scrollTTL: number;
26
26
  _config: any;
27
+ private readonly logger;
27
28
  constructor(config: any, scope?: storeScopeEnum);
28
29
  get scope(): storeScopeEnum;
29
30
  /**
@@ -99,6 +99,7 @@ let esState = esStateEnum.NONE;
99
99
  */
100
100
  class ES7 {
101
101
  constructor(config, scope = storeScopeEnum_1.storeScopeEnum.PUBLIC) {
102
+ this.logger = global.kuzzle.log.child("service:storage:elasticsearch:7");
102
103
  this._config = config;
103
104
  this._scope = scope;
104
105
  this._indexPrefix =
@@ -151,7 +152,7 @@ class ES7 {
151
152
  }
152
153
  if (global.NODE_ENV !== "development" &&
153
154
  this._config.commonMapping.dynamic === "true") {
154
- global.kuzzle.log.warn([
155
+ this.logger.warn([
155
156
  "Your dynamic mapping policy is set to 'true' for new fields.",
156
157
  "Elasticsearch will try to automatically infer mapping for new fields, and those cannot be changed afterward.",
157
158
  'See the "services.storageEngine.commonMapping.dynamic" option in the kuzzlerc configuration file to change this value.',
@@ -2768,7 +2769,7 @@ class ES7 {
2768
2769
  return;
2769
2770
  }
2770
2771
  esState = esStateEnum.AWAITING;
2771
- global.kuzzle.log.info("[ℹ] Trying to connect to Elasticsearch...");
2772
+ this.logger.info("[ℹ] Trying to connect to Elasticsearch...");
2772
2773
  while (esState !== esStateEnum.OK) {
2773
2774
  try {
2774
2775
  // Wait for at least 1 shard to be initialized
@@ -2776,11 +2777,11 @@ class ES7 {
2776
2777
  wait_for_no_initializing_shards: true,
2777
2778
  });
2778
2779
  if (health.body.number_of_pending_tasks === 0) {
2779
- global.kuzzle.log.info("[✔] Elasticsearch is ready");
2780
+ this.logger.info("[✔] Elasticsearch is ready");
2780
2781
  esState = esStateEnum.OK;
2781
2782
  }
2782
2783
  else {
2783
- global.kuzzle.log.info(`[ℹ] Still waiting for Elasticsearch: ${health.body.number_of_pending_tasks} cluster tasks remaining`);
2784
+ this.logger.info(`[ℹ] Still waiting for Elasticsearch: ${health.body.number_of_pending_tasks} cluster tasks remaining`);
2784
2785
  await bluebird_1.default.delay(1000);
2785
2786
  }
2786
2787
  }
@@ -23,6 +23,7 @@ export declare class ES8 {
23
23
  maxScrollDuration: number;
24
24
  scrollTTL: number;
25
25
  _config: any;
26
+ private readonly logger;
26
27
  constructor(config: any, scope?: storeScopeEnum);
27
28
  get scope(): storeScopeEnum;
28
29
  /**
@@ -99,6 +99,7 @@ let esState = esStateEnum.NONE;
99
99
  */
100
100
  class ES8 {
101
101
  constructor(config, scope = storeScopeEnum_1.storeScopeEnum.PUBLIC) {
102
+ this.logger = global.kuzzle.log.child("service:storage:elasticsearch:8");
102
103
  this._config = config;
103
104
  this._scope = scope;
104
105
  this._indexPrefix =
@@ -151,7 +152,7 @@ class ES8 {
151
152
  }
152
153
  if (global.NODE_ENV !== "development" &&
153
154
  this._config.commonMapping.dynamic === "true") {
154
- global.kuzzle.log.warn([
155
+ this.logger.warn([
155
156
  "Your dynamic mapping policy is set to 'true' for new fields.",
156
157
  "Elasticsearch will try to automatically infer mapping for new fields, and those cannot be changed afterward.",
157
158
  'See the "services.storageEngine.commonMapping.dynamic" option in the kuzzlerc configuration file to change this value.',
@@ -2758,7 +2759,7 @@ class ES8 {
2758
2759
  return;
2759
2760
  }
2760
2761
  esState = esStateEnum.AWAITING;
2761
- global.kuzzle.log.info("[ℹ] Trying to connect to Elasticsearch...");
2762
+ this.logger.info("[ℹ] Trying to connect to Elasticsearch...");
2762
2763
  while (esState !== esStateEnum.OK) {
2763
2764
  try {
2764
2765
  // Wait for at least 1 shard to be initialized
@@ -2766,11 +2767,11 @@ class ES8 {
2766
2767
  wait_for_no_initializing_shards: true,
2767
2768
  });
2768
2769
  if (health.number_of_pending_tasks === 0) {
2769
- global.kuzzle.log.info("[✔] Elasticsearch is ready");
2770
+ this.logger.info("[✔] Elasticsearch is ready");
2770
2771
  esState = esStateEnum.OK;
2771
2772
  }
2772
2773
  else {
2773
- global.kuzzle.log.info(`[ℹ] Still waiting for Elasticsearch: ${health.number_of_pending_tasks} cluster tasks remaining`);
2774
+ this.logger.info(`[ℹ] Still waiting for Elasticsearch: ${health.number_of_pending_tasks} cluster tasks remaining`);
2774
2775
  await bluebird_1.default.delay(1000);
2775
2776
  }
2776
2777
  }