kuzzle 2.44.0 → 2.46.0-beta.1

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 (45) hide show
  1. package/check-node-version.js +1 -0
  2. package/lib/api/controllers/adminController.js +2 -1
  3. package/lib/api/controllers/authController.d.ts +1 -0
  4. package/lib/api/controllers/authController.js +2 -1
  5. package/lib/api/controllers/securityController.js +22 -20
  6. package/lib/api/funnel.js +30 -10
  7. package/lib/cluster/command.js +3 -2
  8. package/lib/cluster/idCardHandler.d.ts +1 -0
  9. package/lib/cluster/idCardHandler.js +2 -1
  10. package/lib/cluster/node.js +18 -19
  11. package/lib/cluster/subscriber.js +5 -3
  12. package/lib/core/backend/backend.d.ts +4 -6
  13. package/lib/core/backend/backend.js +25 -23
  14. package/lib/core/cache/cacheEngine.js +3 -1
  15. package/lib/core/network/accessLogger.js +3 -2
  16. package/lib/core/network/entryPoint.js +7 -7
  17. package/lib/core/network/protocols/httpwsProtocol.js +7 -7
  18. package/lib/core/network/protocols/mqttProtocol.js +3 -2
  19. package/lib/core/network/router.js +4 -3
  20. package/lib/core/plugin/pluginContext.d.ts +5 -0
  21. package/lib/core/plugin/pluginContext.js +8 -6
  22. package/lib/core/plugin/pluginsManager.js +13 -5
  23. package/lib/core/realtime/hotelClerk.d.ts +1 -0
  24. package/lib/core/realtime/hotelClerk.js +4 -3
  25. package/lib/core/realtime/notifier.js +2 -1
  26. package/lib/core/security/roleRepository.js +3 -2
  27. package/lib/core/security/securityLoader.js +5 -7
  28. package/lib/core/shared/store.d.ts +1 -0
  29. package/lib/core/shared/store.js +2 -1
  30. package/lib/core/statistics/statistics.js +3 -1
  31. package/lib/core/storage/storageEngine.js +6 -1
  32. package/lib/core/validation/validation.js +6 -5
  33. package/lib/kuzzle/Logger.d.ts +1 -1
  34. package/lib/kuzzle/Logger.js +7 -7
  35. package/lib/kuzzle/dumpGenerator.js +17 -16
  36. package/lib/kuzzle/internalIndexHandler.js +3 -1
  37. package/lib/kuzzle/kuzzle.js +6 -8
  38. package/lib/service/cache/redis.js +4 -0
  39. package/lib/service/storage/7/elasticsearch.d.ts +1 -0
  40. package/lib/service/storage/7/elasticsearch.js +11 -4
  41. package/lib/service/storage/8/elasticsearch.d.ts +1 -0
  42. package/lib/service/storage/8/elasticsearch.js +11 -4
  43. package/lib/service/storage/Elasticsearch.d.ts +1 -0
  44. package/lib/service/storage/Elasticsearch.js +1 -1
  45. package/package.json +19 -19
@@ -31,6 +31,8 @@ class CacheEngine {
31
31
 
32
32
  this.public = new Redis(config.memoryStorage, "public_adapter");
33
33
  this.internal = new Redis(config.internalCache, "internal_adapter");
34
+
35
+ this.logger = global.kuzzle.log.child("core:cache:cacheEngine");
34
36
  }
35
37
 
36
38
  /**
@@ -44,7 +46,7 @@ class CacheEngine {
44
46
  this.registerInternalEvents();
45
47
  this.registerPublicEvents();
46
48
 
47
- global.kuzzle.log.info("[✔] Cache initialized");
49
+ this.logger.info("[✔] Cache initialized");
48
50
  }
49
51
 
50
52
  registerInternalEvents() {
@@ -43,6 +43,7 @@ class AccessLogger {
43
43
  constructor() {
44
44
  this.isActive = false;
45
45
  this.worker = null;
46
+ this.logger = global.kuzzle.log.child("core:network:accessLogger");
46
47
  }
47
48
 
48
49
  async init() {
@@ -50,7 +51,7 @@ class AccessLogger {
50
51
 
51
52
  for (const out of config.logs.transports) {
52
53
  if (out.transport && !ALLOWED_TRANSPORTS.includes(out.transport)) {
53
- global.kuzzle.log.error(
54
+ this.logger.error(
54
55
  `Failed to initialize logger transport "${out.transport}": unsupported transport. Skipped.`,
55
56
  );
56
57
  } else {
@@ -102,7 +103,7 @@ class AccessLogger {
102
103
  size,
103
104
  });
104
105
  } catch (error) {
105
- global.kuzzle.log.error(
106
+ this.logger.error(
106
107
  `Failed to write access log for request "${request.id}": ${error.message}`,
107
108
  );
108
109
  }
@@ -52,6 +52,8 @@ class EntryPoint {
52
52
  this.accessLogger = new AccessLogger();
53
53
 
54
54
  this.isShuttingDown = false;
55
+
56
+ this.logger = global.kuzzle.log.child("core:network:entrypoint");
55
57
  }
56
58
 
57
59
  dispatch(event, data) {
@@ -142,7 +144,7 @@ class EntryPoint {
142
144
  try {
143
145
  this.protocols.get(client.protocol).joinChannel(channel, connectionId);
144
146
  } catch (e) {
145
- global.kuzzle.log.error(
147
+ this.logger.error(
146
148
  `[join] protocol ${client && client.protocol} failed: ${e.message}`,
147
149
  );
148
150
  }
@@ -164,7 +166,7 @@ class EntryPoint {
164
166
  try {
165
167
  this.protocols.get(client.protocol).leaveChannel(channel, connectionId);
166
168
  } catch (e) {
167
- global.kuzzle.log.error(
169
+ this.logger.error(
168
170
  `[leave channel] protocol ${client && client.protocol} failed: ${
169
171
  e.message
170
172
  }`,
@@ -202,9 +204,7 @@ class EntryPoint {
202
204
  return Bluebird.resolve()
203
205
  .then(() => protocol.init(this, new Context()))
204
206
  .catch((error) => {
205
- global.kuzzle.log.error(
206
- `Error during "${manifest.name}" protocol init:`,
207
- );
207
+ this.logger.error(`Error during "${manifest.name}" protocol init:`);
208
208
  throw error;
209
209
  })
210
210
  .timeout(
@@ -318,7 +318,7 @@ class EntryPoint {
318
318
  try {
319
319
  protocol.broadcast(sanitized);
320
320
  } catch (e) {
321
- global.kuzzle.log.error(
321
+ this.logger.error(
322
322
  `[broadcast] protocol ${name} failed: ${e.message}\n${e.stack}`,
323
323
  );
324
324
  }
@@ -348,7 +348,7 @@ class EntryPoint {
348
348
  try {
349
349
  this.protocols.get(client.protocol).notify(removeStacktrace(data));
350
350
  } catch (e) {
351
- global.kuzzle.log.error(
351
+ this.logger.error(
352
352
  `[notify] protocol ${client.protocol} failed: ${e.message}`,
353
353
  );
354
354
  }
@@ -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",
@@ -4,6 +4,7 @@ import { KuzzleRequest, RequestContext, RequestInput } from "../../../index";
4
4
  import { Mutex } from "../../util/mutex";
5
5
  import { BackendCluster } from "../backend";
6
6
  import { EmbeddedSDK } from "../shared/sdk/embeddedSdk";
7
+ import { KuzzleLogger } from "kuzzle-logger/dist";
7
8
  export interface Repository {
8
9
  create(document: JSONObject, options: any): Promise<any>;
9
10
  createOrReplace(document: JSONObject, options: any): Promise<any>;
@@ -139,6 +140,10 @@ export declare class PluginContext {
139
140
  * Decrypted secrets from Kuzzle Vault
140
141
  */
141
142
  secrets: JSONObject;
143
+ /**
144
+ * Logger instance
145
+ */
146
+ logger: KuzzleLogger;
142
147
  /**
143
148
  * Internal Logger
144
149
  */
@@ -125,14 +125,16 @@ class PluginContext {
125
125
  RequestInput: index_1.RequestInput,
126
126
  };
127
127
  Object.freeze(this.constructors);
128
+ this.logger = globalThis.kuzzle.log.child(`${pluginName}`);
128
129
  /* context.log ======================================================== */
130
+ // @deprecated backward compatibility only
129
131
  this.log = {
130
- debug: (msg) => global.kuzzle.log.debug(`[${pluginName}] ${msg}`),
131
- error: (msg) => global.kuzzle.log.error(`[${pluginName}] ${msg}`),
132
- info: (msg) => global.kuzzle.log.info(`[${pluginName}] ${msg}`),
133
- silly: (msg) => global.kuzzle.log.silly(`[${pluginName}] ${msg}`),
134
- verbose: (msg) => global.kuzzle.log.verbose(`[${pluginName}] ${msg}`),
135
- warn: (msg) => global.kuzzle.log.warn(`[${pluginName}] ${msg}`),
132
+ debug: (msg) => this.logger.debug(`[${pluginName}] ${msg}`),
133
+ error: (msg) => this.logger.error(`[${pluginName}] ${msg}`),
134
+ info: (msg) => this.logger.info(`[${pluginName}] ${msg}`),
135
+ silly: (msg) => this.logger.trace(`[${pluginName}] ${msg}`),
136
+ verbose: (msg) => this.logger.trace(`[${pluginName}] ${msg}`),
137
+ warn: (msg) => this.logger.warn(`[${pluginName}] ${msg}`),
136
138
  };
137
139
  Object.freeze(this.log);
138
140
  /* context.accessors ================================================== */
@@ -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
  }
@@ -6,7 +6,7 @@ import { KuzzleConfiguration } from "../../";
6
6
  export declare class Logger extends KuzzleLogger {
7
7
  private warnedForSillyDeprecation;
8
8
  private warnedForVerboseDeprecation;
9
- constructor(kuzzleConfig: KuzzleConfiguration);
9
+ constructor(kuzzleConfig: KuzzleConfiguration, namespace?: string);
10
10
  /**
11
11
  * Logs a message with the "silly" level.
12
12
  *
@@ -26,15 +26,18 @@ const kuzzle_logger_1 = require("kuzzle-logger");
26
26
  * The Logger class provides logging functionality for Kuzzle.
27
27
  */
28
28
  class Logger extends kuzzle_logger_1.KuzzleLogger {
29
- constructor(kuzzleConfig) {
29
+ constructor(kuzzleConfig, namespace = "kuzzle") {
30
30
  const config = kuzzleConfig.server.appLogs;
31
31
  const deprecatedConfig = kuzzleConfig.plugins["kuzzle-plugin-logger"];
32
32
  const getMergingObject = () => {
33
33
  const mergingObject = {};
34
- mergingObject.namespace = "kuzzle";
34
+ mergingObject.namespace = namespace;
35
35
  mergingObject.failsafeMode = Boolean(kuzzleConfig.plugins.common.failsafeMode);
36
- if (global.kuzzle.id) {
37
- mergingObject.nodeId = global.kuzzle.id;
36
+ if (global.nodeId) {
37
+ mergingObject.nodeId = global.nodeId;
38
+ }
39
+ if (namespace !== "kuzzle") {
40
+ return mergingObject;
38
41
  }
39
42
  if (global.kuzzle.asyncStore?.exists() &&
40
43
  global.kuzzle.asyncStore?.has("REQUEST")) {
@@ -74,9 +77,6 @@ class Logger extends kuzzle_logger_1.KuzzleLogger {
74
77
  if (deprecatedConfig) {
75
78
  this.warn("[DEPRECATED] The plugins.kuzzle-plugin-logger configuration is deprecated, use server.logs instead.");
76
79
  }
77
- global.kuzzle.onPipe("kuzzle:shutdown", async () => {
78
- await this.flush();
79
- });
80
80
  }
81
81
  /**
82
82
  * Logs a message with the "silly" level.