kuzzle 2.42.0 → 2.43.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.
- package/lib/config/default.config.js +12 -11
- package/lib/core/backend/applicationManager.d.ts +2 -1
- package/lib/core/backend/internalLogger.d.ts +14 -0
- package/lib/core/backend/internalLogger.js +26 -0
- package/lib/core/plugin/pluginsManager.js +1 -4
- package/lib/kuzzle/Logger.d.ts +26 -0
- package/lib/kuzzle/Logger.js +114 -0
- package/lib/kuzzle/kuzzle.d.ts +1 -1
- package/lib/kuzzle/kuzzle.js +2 -2
- package/lib/service/storage/7/elasticsearch.js +10 -8
- package/lib/service/storage/8/elasticsearch.js +8 -6
- package/lib/types/config/PluginsConfiguration.d.ts +5 -12
- package/lib/types/config/ServerConfiguration.d.ts +3 -1
- package/lib/util/debug.js +15 -1
- package/package.json +7 -2
- package/lib/kuzzle/log.js +0 -74
|
@@ -70,16 +70,7 @@ const defaultConfig = {
|
|
|
70
70
|
initTimeout: 10000,
|
|
71
71
|
maxConcurrentPipes: 50,
|
|
72
72
|
pipesBufferSize: 50000,
|
|
73
|
-
include: ["kuzzle-plugin-
|
|
74
|
-
},
|
|
75
|
-
"kuzzle-plugin-logger": {
|
|
76
|
-
services: {
|
|
77
|
-
stdout: {
|
|
78
|
-
level: "info",
|
|
79
|
-
addDate: true,
|
|
80
|
-
dateFormat: "YYYY-MM-DD HH-mm-ss",
|
|
81
|
-
},
|
|
82
|
-
},
|
|
73
|
+
include: ["kuzzle-plugin-auth-passport-local"],
|
|
83
74
|
},
|
|
84
75
|
"kuzzle-plugin-auth-passport-local": {
|
|
85
76
|
algorithm: "sha512",
|
|
@@ -194,10 +185,20 @@ const defaultConfig = {
|
|
|
194
185
|
},
|
|
195
186
|
},
|
|
196
187
|
server: {
|
|
188
|
+
appLogs: {
|
|
189
|
+
level: "info",
|
|
190
|
+
transport: {
|
|
191
|
+
targets: [
|
|
192
|
+
{
|
|
193
|
+
preset: "stdout",
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
197
198
|
logs: {
|
|
198
199
|
transports: [
|
|
199
200
|
{
|
|
200
|
-
|
|
201
|
+
preset: "console",
|
|
201
202
|
level: "info",
|
|
202
203
|
stderrLevels: [],
|
|
203
204
|
silent: true,
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ApplicationManager } from "./index";
|
|
2
2
|
export declare class InternalLogger extends ApplicationManager {
|
|
3
|
+
/**
|
|
4
|
+
* Logs a trace message
|
|
5
|
+
*/
|
|
6
|
+
trace(message: any): void;
|
|
3
7
|
/**
|
|
4
8
|
* Logs an debug message
|
|
5
9
|
*/
|
|
@@ -16,9 +20,19 @@ export declare class InternalLogger extends ApplicationManager {
|
|
|
16
20
|
* Logs an error message
|
|
17
21
|
*/
|
|
18
22
|
error(message: any): void;
|
|
23
|
+
/**
|
|
24
|
+
* Logs a fatal message
|
|
25
|
+
*/
|
|
26
|
+
fatal(message: any): void;
|
|
19
27
|
/**
|
|
20
28
|
* Logs a verbose message
|
|
29
|
+
*
|
|
30
|
+
* @deprecated Use InternalLogger.debug instead.
|
|
21
31
|
*/
|
|
22
32
|
verbose(message: any): void;
|
|
33
|
+
/**
|
|
34
|
+
* Change the log level
|
|
35
|
+
*/
|
|
36
|
+
level(level: string): void;
|
|
23
37
|
private _log;
|
|
24
38
|
}
|
|
@@ -27,6 +27,12 @@ exports.InternalLogger = void 0;
|
|
|
27
27
|
const util_1 = __importDefault(require("util"));
|
|
28
28
|
const index_1 = require("./index");
|
|
29
29
|
class InternalLogger extends index_1.ApplicationManager {
|
|
30
|
+
/**
|
|
31
|
+
* Logs a trace message
|
|
32
|
+
*/
|
|
33
|
+
trace(message) {
|
|
34
|
+
this._log("trace", message);
|
|
35
|
+
}
|
|
30
36
|
/**
|
|
31
37
|
* Logs an debug message
|
|
32
38
|
*/
|
|
@@ -51,12 +57,32 @@ class InternalLogger extends index_1.ApplicationManager {
|
|
|
51
57
|
error(message) {
|
|
52
58
|
this._log("error", message);
|
|
53
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Logs a fatal message
|
|
62
|
+
*/
|
|
63
|
+
fatal(message) {
|
|
64
|
+
this._log("fatal", message);
|
|
65
|
+
}
|
|
54
66
|
/**
|
|
55
67
|
* Logs a verbose message
|
|
68
|
+
*
|
|
69
|
+
* @deprecated Use InternalLogger.debug instead.
|
|
56
70
|
*/
|
|
57
71
|
verbose(message) {
|
|
58
72
|
this._log("verbose", message);
|
|
59
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Change the log level
|
|
76
|
+
*/
|
|
77
|
+
level(level) {
|
|
78
|
+
if (!this._application.started) {
|
|
79
|
+
// eslint-disable-next-line no-console
|
|
80
|
+
console.log("InternalLogger.level() is not available before the application is started");
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this._kuzzle.log.level = level;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
60
86
|
_log(level, message) {
|
|
61
87
|
if (!this._application.started) {
|
|
62
88
|
// eslint-disable-next-line no-console
|
|
@@ -43,10 +43,7 @@ const strategyError = kerror.wrap("plugin", "strategy");
|
|
|
43
43
|
const controllerError = kerror.wrap("plugin", "controller");
|
|
44
44
|
|
|
45
45
|
// Without those plugins, Kuzzle won't start at all.
|
|
46
|
-
const CORE_PLUGINS = [
|
|
47
|
-
"kuzzle-plugin-logger",
|
|
48
|
-
"kuzzle-plugin-auth-passport-local",
|
|
49
|
-
];
|
|
46
|
+
const CORE_PLUGINS = ["kuzzle-plugin-auth-passport-local"];
|
|
50
47
|
|
|
51
48
|
/**
|
|
52
49
|
* @class PluginsManager
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { KuzzleLogger } from "kuzzle-logger";
|
|
2
|
+
import { KuzzleConfiguration } from "../../";
|
|
3
|
+
/**
|
|
4
|
+
* The Logger class provides logging functionality for Kuzzle.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Logger extends KuzzleLogger {
|
|
7
|
+
private warnedForSillyDeprecation;
|
|
8
|
+
private warnedForVerboseDeprecation;
|
|
9
|
+
constructor(kuzzleConfig: KuzzleConfiguration);
|
|
10
|
+
/**
|
|
11
|
+
* Logs a message with the "silly" level.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated Use Logger.trace instead.
|
|
14
|
+
* @param message - The message to log.
|
|
15
|
+
*/
|
|
16
|
+
silly(message: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Logs a message with the "verbose" level.
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Use Logger.debug instead.
|
|
21
|
+
* @param message - The message to log.
|
|
22
|
+
*/
|
|
23
|
+
verbose(message: string): void;
|
|
24
|
+
getLevel(): string;
|
|
25
|
+
setLevel(level: string): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Kuzzle, a backend software, self-hostable and ready to use
|
|
4
|
+
* to power modern apps
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2015-2022 Kuzzle
|
|
7
|
+
* mailto: support AT kuzzle.io
|
|
8
|
+
* website: http://kuzzle.io
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.Logger = void 0;
|
|
24
|
+
const kuzzle_logger_1 = require("kuzzle-logger");
|
|
25
|
+
/**
|
|
26
|
+
* The Logger class provides logging functionality for Kuzzle.
|
|
27
|
+
*/
|
|
28
|
+
class Logger extends kuzzle_logger_1.KuzzleLogger {
|
|
29
|
+
constructor(kuzzleConfig) {
|
|
30
|
+
const config = kuzzleConfig.server.appLogs;
|
|
31
|
+
const deprecatedConfig = kuzzleConfig.plugins["kuzzle-plugin-logger"];
|
|
32
|
+
const getMergingObject = () => {
|
|
33
|
+
const mergingObject = {};
|
|
34
|
+
mergingObject.failsafeMode = Boolean(kuzzleConfig.plugins.common.failsafeMode);
|
|
35
|
+
if (global.kuzzle.id) {
|
|
36
|
+
mergingObject.nodeId = global.kuzzle.id;
|
|
37
|
+
}
|
|
38
|
+
if (global.kuzzle.asyncStore?.exists() &&
|
|
39
|
+
global.kuzzle.asyncStore?.has("REQUEST")) {
|
|
40
|
+
const request = global.kuzzle.asyncStore.get("REQUEST");
|
|
41
|
+
mergingObject.requestId = request.id;
|
|
42
|
+
}
|
|
43
|
+
return mergingObject;
|
|
44
|
+
};
|
|
45
|
+
super(deprecatedConfig?.services
|
|
46
|
+
? {
|
|
47
|
+
getMergingObject,
|
|
48
|
+
serviceName: "kuzzle",
|
|
49
|
+
transport: {
|
|
50
|
+
targets: Object.entries(deprecatedConfig.services).map(([serviceName, serviceConfig]) => {
|
|
51
|
+
if (serviceName === "stdout") {
|
|
52
|
+
let level = serviceConfig.level || "info";
|
|
53
|
+
if (level === "silly") {
|
|
54
|
+
level = "trace";
|
|
55
|
+
}
|
|
56
|
+
if (level === "verbose") {
|
|
57
|
+
level = "debug";
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
level,
|
|
61
|
+
preset: "stdout",
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
: {
|
|
68
|
+
...config,
|
|
69
|
+
getMergingObject,
|
|
70
|
+
});
|
|
71
|
+
this.warnedForSillyDeprecation = false;
|
|
72
|
+
this.warnedForVerboseDeprecation = false;
|
|
73
|
+
if (deprecatedConfig) {
|
|
74
|
+
this.warn("[DEPRECATED] The plugins.kuzzle-plugin-logger configuration is deprecated, use server.logs instead.");
|
|
75
|
+
}
|
|
76
|
+
global.kuzzle.onPipe("kuzzle:shutdown", async () => {
|
|
77
|
+
await this.flush();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Logs a message with the "silly" level.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated Use Logger.trace instead.
|
|
84
|
+
* @param message - The message to log.
|
|
85
|
+
*/
|
|
86
|
+
silly(message) {
|
|
87
|
+
if (!this.warnedForSillyDeprecation) {
|
|
88
|
+
this.warnedForSillyDeprecation = true;
|
|
89
|
+
this.warn("[DEPRECATED] Logger.silly is deprecated, use Logger.trace instead. Logging messages at trace level.");
|
|
90
|
+
}
|
|
91
|
+
this.trace(message);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Logs a message with the "verbose" level.
|
|
95
|
+
*
|
|
96
|
+
* @deprecated Use Logger.debug instead.
|
|
97
|
+
* @param message - The message to log.
|
|
98
|
+
*/
|
|
99
|
+
verbose(message) {
|
|
100
|
+
if (!this.warnedForVerboseDeprecation) {
|
|
101
|
+
this.warnedForVerboseDeprecation = true;
|
|
102
|
+
this.warn("[DEPRECATED] Logger.verbose is deprecated, use Logger.debug instead. Logging messages at debug level.");
|
|
103
|
+
}
|
|
104
|
+
this.debug(message);
|
|
105
|
+
}
|
|
106
|
+
getLevel() {
|
|
107
|
+
return this.level;
|
|
108
|
+
}
|
|
109
|
+
setLevel(level) {
|
|
110
|
+
this.level = level;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.Logger = Logger;
|
|
114
|
+
//# sourceMappingURL=Logger.js.map
|
package/lib/kuzzle/kuzzle.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { ImportConfig, InstallationConfig, StartOptions, SupportConfig } from ".
|
|
|
12
12
|
import KuzzleEventEmitter from "./event/KuzzleEventEmitter";
|
|
13
13
|
import InternalIndexHandler from "./internalIndexHandler";
|
|
14
14
|
import kuzzleStateEnum from "./kuzzleStateEnum";
|
|
15
|
-
import Logger from "./
|
|
15
|
+
import { Logger } from "./Logger";
|
|
16
16
|
import vault from "./vault";
|
|
17
17
|
export declare const BACKEND_IMPORT_KEY = "backend:init:import";
|
|
18
18
|
declare class Kuzzle extends KuzzleEventEmitter {
|
package/lib/kuzzle/kuzzle.js
CHANGED
|
@@ -78,7 +78,7 @@ const dumpGenerator_1 = __importDefault(require("./dumpGenerator"));
|
|
|
78
78
|
const KuzzleEventEmitter_1 = __importDefault(require("./event/KuzzleEventEmitter"));
|
|
79
79
|
const internalIndexHandler_1 = __importDefault(require("./internalIndexHandler"));
|
|
80
80
|
const kuzzleStateEnum_1 = __importDefault(require("./kuzzleStateEnum"));
|
|
81
|
-
const
|
|
81
|
+
const Logger_1 = require("./Logger");
|
|
82
82
|
const vault_1 = __importDefault(require("./vault"));
|
|
83
83
|
exports.BACKEND_IMPORT_KEY = "backend:init:import";
|
|
84
84
|
let _kuzzle = null;
|
|
@@ -105,7 +105,7 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
105
105
|
global.kuzzle = this;
|
|
106
106
|
this._state = kuzzleStateEnum_1.default.STARTING;
|
|
107
107
|
this.config = config;
|
|
108
|
-
this.log = new
|
|
108
|
+
this.log = new Logger_1.Logger(config);
|
|
109
109
|
this.rootPath = path_1.default.resolve(path_1.default.join(__dirname, "../.."));
|
|
110
110
|
this.internalIndex = new internalIndexHandler_1.default();
|
|
111
111
|
this.pluginsManager = new pluginsManager_1.default();
|
|
@@ -955,6 +955,13 @@ class ES7 {
|
|
|
955
955
|
* @returns {Promise.<{ successes: [_id, _source, _status], errors: [ document, status, reason ] }>}
|
|
956
956
|
*/
|
|
957
957
|
async bulkUpdateByQuery(index, collection, query, changes, { refresh = false, } = {}) {
|
|
958
|
+
const esRequest = {
|
|
959
|
+
body: {
|
|
960
|
+
query: this._sanitizeSearchBody({ query }).query,
|
|
961
|
+
},
|
|
962
|
+
index: this._getAlias(index, collection),
|
|
963
|
+
refresh,
|
|
964
|
+
};
|
|
958
965
|
const script = {
|
|
959
966
|
params: {},
|
|
960
967
|
source: "",
|
|
@@ -964,14 +971,9 @@ class ES7 {
|
|
|
964
971
|
script.source += `ctx._source.${key} = params['${key}'];`;
|
|
965
972
|
script.params[key] = value;
|
|
966
973
|
}
|
|
967
|
-
|
|
968
|
-
body
|
|
969
|
-
|
|
970
|
-
script,
|
|
971
|
-
},
|
|
972
|
-
index: this._getAlias(index, collection),
|
|
973
|
-
refresh,
|
|
974
|
-
};
|
|
974
|
+
if (script.source !== "") {
|
|
975
|
+
esRequest.body.script = script;
|
|
976
|
+
}
|
|
975
977
|
(0, debug_1.default)("Bulk Update by query: %o", esRequest);
|
|
976
978
|
let response;
|
|
977
979
|
try {
|
|
@@ -971,6 +971,11 @@ class ES8 {
|
|
|
971
971
|
* @returns {Promise.<{ successes: [_id, _source, _status], errors: [ document, status, reason ] }>}
|
|
972
972
|
*/
|
|
973
973
|
async bulkUpdateByQuery(index, collection, query, changes, { refresh = false, } = {}) {
|
|
974
|
+
const esRequest = {
|
|
975
|
+
index: this._getAlias(index, collection),
|
|
976
|
+
query: this._sanitizeSearchBody({ query }).query,
|
|
977
|
+
refresh,
|
|
978
|
+
};
|
|
974
979
|
const script = {
|
|
975
980
|
params: {},
|
|
976
981
|
source: "",
|
|
@@ -980,12 +985,9 @@ class ES8 {
|
|
|
980
985
|
script.source += `ctx._source.${key} = params['${key}'];`;
|
|
981
986
|
script.params[key] = value;
|
|
982
987
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
refresh,
|
|
987
|
-
script,
|
|
988
|
-
};
|
|
988
|
+
if (script.source !== "") {
|
|
989
|
+
esRequest.script = script;
|
|
990
|
+
}
|
|
989
991
|
(0, debug_1.default)("Bulk Update by query: %o", esRequest);
|
|
990
992
|
let response;
|
|
991
993
|
try {
|
|
@@ -27,7 +27,7 @@ export type PluginsConfiguration = {
|
|
|
27
27
|
* Edit this list to deactivate one or more of those plugins.
|
|
28
28
|
* NOTE: this list does not control plugins installed manually.
|
|
29
29
|
*
|
|
30
|
-
* @default ["kuzzle-plugin-
|
|
30
|
+
* @default ["kuzzle-plugin-auth-passport-local"]
|
|
31
31
|
*/
|
|
32
32
|
include: string[];
|
|
33
33
|
/**
|
|
@@ -67,23 +67,16 @@ export type PluginsConfiguration = {
|
|
|
67
67
|
pipesBufferSize: number;
|
|
68
68
|
};
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* This plugin use Winston to transport the logs.
|
|
73
|
-
*
|
|
74
|
-
* @see https://github.com/kuzzleio/kuzzle-plugin-logger
|
|
70
|
+
* Logger plugin configuration.
|
|
71
|
+
* @deprecated use server.logs
|
|
75
72
|
*/
|
|
76
|
-
"kuzzle-plugin-logger"
|
|
73
|
+
"kuzzle-plugin-logger"?: {
|
|
77
74
|
/**
|
|
78
|
-
*
|
|
75
|
+
* Services declaration
|
|
79
76
|
*/
|
|
80
77
|
services: {
|
|
81
78
|
/**
|
|
82
79
|
* Print logs to STDOUT
|
|
83
|
-
*
|
|
84
|
-
* @default
|
|
85
|
-
*
|
|
86
|
-
* @see https://github.com/winstonjs/winston/blob/master/docs/transports.md#console-transport
|
|
87
80
|
*/
|
|
88
81
|
stdout: {
|
|
89
82
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KuzzleLoggerConfig } from "kuzzle-logger";
|
|
1
2
|
import { JSONObject } from "../../../index";
|
|
2
3
|
export type ServerConfiguration = {
|
|
3
4
|
/**
|
|
@@ -16,8 +17,9 @@ export type ServerConfiguration = {
|
|
|
16
17
|
*/
|
|
17
18
|
port: number;
|
|
18
19
|
/**
|
|
19
|
-
* Configuration section for Kuzzle
|
|
20
|
+
* Configuration section for Kuzzle logs.
|
|
20
21
|
*/
|
|
22
|
+
appLogs: Omit<KuzzleLoggerConfig, "getMergingObject">;
|
|
21
23
|
logs: {
|
|
22
24
|
/**
|
|
23
25
|
* An array of Winston transports configurations to output access
|
package/lib/util/debug.js
CHANGED
|
@@ -34,4 +34,18 @@ debug.formatters.a = (value) => {
|
|
|
34
34
|
return util.inspect(value, inspectOpts).replace(/\s*\n\s*/g, " ");
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
debug.formatArgs = () => {};
|
|
38
|
+
|
|
39
|
+
function createDebug(namespace) {
|
|
40
|
+
const myDebug = debug(namespace);
|
|
41
|
+
myDebug.log = (...args) => {
|
|
42
|
+
if (!["debug", "trace"].includes(global.kuzzle.log.level)) {
|
|
43
|
+
global.kuzzle.log.level = "debug";
|
|
44
|
+
}
|
|
45
|
+
global.kuzzle.log.debug({ namespace }, ...args);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return myDebug;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = createDebug;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.43.0",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"bin": "bin/start-kuzzle-server",
|
|
7
7
|
"scripts": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"json2yaml": "1.1.0",
|
|
46
46
|
"jsonwebtoken": "9.0.2",
|
|
47
47
|
"koncorde": "4.6.0",
|
|
48
|
+
"kuzzle-logger": "^1.2.0",
|
|
48
49
|
"kuzzle-plugin-auth-passport-local": "6.4.1",
|
|
49
|
-
"kuzzle-plugin-logger": "3.0.3",
|
|
50
50
|
"kuzzle-sdk": "^7.15.0",
|
|
51
51
|
"kuzzle-vault": "2.1.0",
|
|
52
52
|
"lodash": "4.17.21",
|
|
@@ -97,6 +97,11 @@
|
|
|
97
97
|
"mock-require": "3.0.3",
|
|
98
98
|
"mqtt": "5.10.4",
|
|
99
99
|
"nyc": "17.1.0",
|
|
100
|
+
"pino-caller": "^3.4.0",
|
|
101
|
+
"pino-elasticsearch": "^8.1.0",
|
|
102
|
+
"pino-loki": "^2.5.0",
|
|
103
|
+
"pino-pretty": "^13.0.0",
|
|
104
|
+
"pino-transport-ecs": "^1.1.0",
|
|
100
105
|
"request": "2.88.2",
|
|
101
106
|
"request-promise": "4.2.6",
|
|
102
107
|
"rewire": "5.0.0",
|
package/lib/kuzzle/log.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
|
-
* to power modern apps
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2015-2022 Kuzzle
|
|
6
|
-
* mailto: support AT kuzzle.io
|
|
7
|
-
* website: http://kuzzle.io
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
* you may not use this file except in compliance with the License.
|
|
11
|
-
* You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
"use strict";
|
|
23
|
-
|
|
24
|
-
class Logger {
|
|
25
|
-
constructor() {
|
|
26
|
-
this.logMethods = ["info", "warn", "error", "silly", "debug", "verbose"];
|
|
27
|
-
|
|
28
|
-
this.failsafeModeString = global.kuzzle.config.plugins.common.failsafeMode
|
|
29
|
-
? "[FAILSAFE MODE] "
|
|
30
|
-
: "";
|
|
31
|
-
|
|
32
|
-
this._useConsole();
|
|
33
|
-
|
|
34
|
-
global.kuzzle.once("core:kuzzleStart", this._useLogger.bind(this));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
_useConsole() {
|
|
38
|
-
// until kuzzle has started, use the console to print logs
|
|
39
|
-
for (const method of this.logMethods) {
|
|
40
|
-
this[method] = (message) => {
|
|
41
|
-
/* eslint-disable-next-line no-console */
|
|
42
|
-
const writer = console[method] || console.log;
|
|
43
|
-
|
|
44
|
-
writer(`${this.failsafeModeString}${message}`);
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
_useLogger() {
|
|
50
|
-
// when kuzzle has started, use the event to dispatch logs
|
|
51
|
-
for (const method of this.logMethods) {
|
|
52
|
-
this[method] = (message) => {
|
|
53
|
-
if (
|
|
54
|
-
global.kuzzle.asyncStore.exists() &&
|
|
55
|
-
global.kuzzle.asyncStore.has("REQUEST")
|
|
56
|
-
) {
|
|
57
|
-
const request = global.kuzzle.asyncStore.get("REQUEST");
|
|
58
|
-
|
|
59
|
-
global.kuzzle.emit(
|
|
60
|
-
`log:${method}`,
|
|
61
|
-
`[${global.kuzzle.id}] ${this.failsafeModeString}[${request.id}] ${message}`,
|
|
62
|
-
);
|
|
63
|
-
} else {
|
|
64
|
-
global.kuzzle.emit(
|
|
65
|
-
`log:${method}`,
|
|
66
|
-
`[${global.kuzzle.id}] ${this.failsafeModeString}${message}`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
module.exports = Logger;
|