@leyyo/common 1.3.18 → 1.3.19
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/dist/base/index.d.ts +3 -3
- package/dist/base/index.js +3 -3
- package/dist/base/index.types.d.ts +3 -70
- package/dist/base/index.types.js +0 -32
- package/dist/base/leyyo.d.ts +0 -3
- package/dist/base/leyyo.js +8 -19
- package/dist/class/index.d.ts +2 -2
- package/dist/class/index.js +2 -2
- package/dist/class/index.types.d.ts +0 -20
- package/dist/class/list.d.ts +0 -6
- package/dist/class/list.js +0 -6
- package/dist/class/logger.instance.d.ts +6 -11
- package/dist/class/logger.instance.js +11 -25
- package/dist/common/deploy.common.d.ts +0 -16
- package/dist/common/deploy.common.js +4 -21
- package/dist/common/enum.pool.d.ts +5 -13
- package/dist/common/enum.pool.js +16 -17
- package/dist/common/error.common.d.ts +0 -30
- package/dist/common/error.common.js +33 -69
- package/dist/common/error.pool.d.ts +1 -10
- package/dist/common/error.pool.js +2 -13
- package/dist/common/event.common.d.ts +0 -8
- package/dist/common/event.common.js +15 -25
- package/dist/common/index.d.ts +11 -11
- package/dist/common/index.js +11 -11
- package/dist/common/index.types.d.ts +12 -435
- package/dist/common/index.types.js +0 -1
- package/dist/common/inert.d.ts +1 -49
- package/dist/common/inert.js +35 -64
- package/dist/common/lifecycle.common.d.ts +0 -14
- package/dist/common/lifecycle.common.js +13 -29
- package/dist/common/literal.pool.d.ts +1 -12
- package/dist/common/literal.pool.js +3 -18
- package/dist/common/log.common.d.ts +0 -54
- package/dist/common/log.common.js +62 -147
- package/dist/common/repo.common.d.ts +0 -188
- package/dist/common/repo.common.js +23 -239
- package/dist/const/index.d.ts +0 -7
- package/dist/const/index.js +28 -36
- package/dist/enum/index.d.ts +1 -1
- package/dist/enum/index.js +1 -1
- package/dist/enum/log-level.d.ts +1 -4
- package/dist/enum/log-level.js +1 -1
- package/dist/error/caused.error.d.ts +0 -10
- package/dist/error/caused.error.js +0 -10
- package/dist/error/developer.error.d.ts +1 -10
- package/dist/error/developer.error.js +6 -25
- package/dist/error/http.error.d.ts +0 -13
- package/dist/error/http.error.js +1 -8
- package/dist/error/index.d.ts +7 -7
- package/dist/error/index.js +7 -7
- package/dist/error/index.types.d.ts +1 -150
- package/dist/error/invalid-value.error.d.ts +0 -3
- package/dist/error/invalid-value.error.js +1 -4
- package/dist/error/leyyo.error.d.ts +0 -33
- package/dist/error/leyyo.error.js +25 -57
- package/dist/error/multiple.error.d.ts +0 -6
- package/dist/error/multiple.error.js +2 -9
- package/dist/function/define-loader.d.ts +0 -6
- package/dist/function/define-loader.js +0 -6
- package/dist/function/delay.d.ts +0 -8
- package/dist/function/delay.js +0 -9
- package/dist/function/delete-prop.d.ts +0 -21
- package/dist/function/delete-prop.js +6 -28
- package/dist/function/empty-fn.d.ts +0 -6
- package/dist/function/empty-fn.js +1 -9
- package/dist/function/extended-type.d.ts +0 -6
- package/dist/function/extended-type.js +18 -24
- package/dist/function/get-fqn.d.ts +0 -6
- package/dist/function/get-fqn.js +2 -8
- package/dist/function/get-prop.d.ts +0 -21
- package/dist/function/get-prop.js +5 -26
- package/dist/function/get-stat.d.ts +0 -20
- package/dist/function/get-stat.js +7 -2
- package/dist/function/has-fqn.d.ts +0 -6
- package/dist/function/has-fqn.js +2 -8
- package/dist/function/index.d.ts +40 -40
- package/dist/function/index.js +40 -40
- package/dist/function/index.types.d.ts +1 -1
- package/dist/function/is-anonymous-name.js +1 -1
- package/dist/function/is-class.d.ts +0 -6
- package/dist/function/is-class.js +2 -20
- package/dist/function/is-empty.d.ts +0 -11
- package/dist/function/is-empty.js +1 -12
- package/dist/function/is-filled-arr.d.ts +0 -9
- package/dist/function/is-filled-arr.js +0 -9
- package/dist/function/is-filled-obj.d.ts +0 -9
- package/dist/function/is-filled-obj.js +0 -9
- package/dist/function/is-obj.d.ts +0 -8
- package/dist/function/is-obj.js +1 -9
- package/dist/function/is-test.d.ts +0 -8
- package/dist/function/is-test.js +3 -19
- package/dist/function/is-text.d.ts +0 -10
- package/dist/function/is-text.js +1 -11
- package/dist/function/jitter-interval.d.ts +0 -9
- package/dist/function/jitter-interval.js +2 -18
- package/dist/function/load-config.d.ts +0 -19
- package/dist/function/load-config.js +10 -61
- package/dist/function/on-fqn-set.js +3 -3
- package/dist/function/one-or-more.d.ts +0 -6
- package/dist/function/one-or-more.js +0 -7
- package/dist/function/opt-add.d.ts +0 -8
- package/dist/function/opt-add.js +2 -10
- package/dist/function/opt-append.d.ts +0 -7
- package/dist/function/opt-append.js +0 -7
- package/dist/function/opt-check.d.ts +0 -6
- package/dist/function/opt-check.js +2 -9
- package/dist/function/opt-clone.d.ts +0 -6
- package/dist/function/opt-clone.js +0 -7
- package/dist/function/opt-field.d.ts +0 -8
- package/dist/function/opt-field.js +6 -14
- package/dist/function/opt-fn.d.ts +0 -6
- package/dist/function/opt-fn.js +0 -7
- package/dist/function/random-test-no.d.ts +0 -5
- package/dist/function/random-test-no.js +0 -5
- package/dist/function/remove-fqn.d.ts +0 -8
- package/dist/function/remove-fqn.js +3 -12
- package/dist/function/run-exporter.d.ts +0 -5
- package/dist/function/run-exporter.js +3 -17
- package/dist/function/secure-clone.js +3 -3
- package/dist/function/secure-json.d.ts +0 -35
- package/dist/function/secure-json.js +12 -54
- package/dist/function/set-anonymous-fqn.js +4 -5
- package/dist/function/set-anonymous-name.js +14 -14
- package/dist/function/set-fqn.d.ts +0 -7
- package/dist/function/set-fqn.js +8 -15
- package/dist/function/set-prop.d.ts +0 -24
- package/dist/function/set-prop.js +6 -30
- package/dist/function/stamp-loader.d.ts +0 -6
- package/dist/function/stamp-loader.js +1 -7
- package/dist/function/test-case.d.ts +0 -7
- package/dist/function/test-case.js +3 -10
- package/dist/function/test-name.d.ts +0 -7
- package/dist/function/test-name.js +2 -9
- package/dist/function/trigger-fqn.js +2 -3
- package/dist/index.d.ts +10 -10
- package/dist/index.foretell.js +7 -10
- package/dist/index.js +10 -11
- package/dist/index.loader.js +1 -8
- package/dist/init/index.js +5 -7
- package/dist/sys/index.d.ts +2 -2
- package/dist/sys/index.js +2 -2
- package/dist/sys/leyyo-storage.d.ts +0 -7
- package/dist/sys/leyyo-storage.js +5 -28
- package/dist/sys/package-json.js +5 -5
- package/package.json +16 -31
|
@@ -1,105 +1,66 @@
|
|
|
1
1
|
import { FQN } from "../internal.js";
|
|
2
|
-
import { getFqn, hasFqn, isEmpty, isFilledObj, isObj, onFqnSet, secureJson, testCase } from "../function/index.js";
|
|
2
|
+
import { getFqn, hasFqn, isEmpty, isFilledObj, isObj, onFqnSet, secureJson, testCase, } from "../function/index.js";
|
|
3
3
|
import { KEY_LOG_ALREADY } from "../const/index.js";
|
|
4
4
|
const where = `${FQN}.LogCommon`;
|
|
5
|
-
const emptyWhere =
|
|
6
|
-
// noinspection JSUnusedGlobalSymbols
|
|
5
|
+
const emptyWhere = "".padStart(20);
|
|
7
6
|
export class LogCommon {
|
|
8
7
|
leyyo;
|
|
9
|
-
// region properties
|
|
10
|
-
/**
|
|
11
|
-
* Loggers
|
|
12
|
-
* */
|
|
13
8
|
_loggers;
|
|
14
|
-
/**
|
|
15
|
-
* Local console colors
|
|
16
|
-
*
|
|
17
|
-
* @type {LocalColorLike}
|
|
18
|
-
* */
|
|
19
9
|
_localColor = {
|
|
20
|
-
bold:
|
|
21
|
-
normal:
|
|
22
|
-
end:
|
|
23
|
-
param:
|
|
10
|
+
bold: "\x1b[1m",
|
|
11
|
+
normal: "\x1b[21m",
|
|
12
|
+
end: "\x1b[0m",
|
|
13
|
+
param: "\x1b[90m",
|
|
24
14
|
levels: {
|
|
25
|
-
fatal: [true,
|
|
26
|
-
error: [false,
|
|
27
|
-
warn: [false,
|
|
28
|
-
info: [false,
|
|
29
|
-
debug: [false,
|
|
30
|
-
trace: [false,
|
|
31
|
-
}
|
|
15
|
+
fatal: [true, "\x1b[31m", "\x1b[91m"],
|
|
16
|
+
error: [false, "\x1b[31m", "\x1b[91m"],
|
|
17
|
+
warn: [false, "\x1b[35m", "\x1b[95m"],
|
|
18
|
+
info: [false, "\x1b[32m", "\x1b[92m"],
|
|
19
|
+
debug: [false, "\x1b[33m", "\x1b[93m"],
|
|
20
|
+
trace: [false, "\x1b[36m", "\x1b[96m"],
|
|
21
|
+
},
|
|
32
22
|
};
|
|
33
23
|
_logFormatter;
|
|
34
24
|
_logDeploymentStyler;
|
|
35
25
|
_logLocalStyler;
|
|
36
26
|
_logStyler;
|
|
37
27
|
_contextFinder;
|
|
38
|
-
// endregion properties
|
|
39
28
|
constructor(leyyo) {
|
|
40
29
|
this.leyyo = leyyo;
|
|
41
30
|
this._loggers = this.leyyo.repoCommon.newMap(`${where}.loggers`);
|
|
42
31
|
this._defaults();
|
|
43
32
|
}
|
|
44
|
-
// region setters
|
|
45
|
-
/**
|
|
46
|
-
* Set formatter
|
|
47
|
-
*
|
|
48
|
-
* @param {function} fn - lambda for formatter
|
|
49
|
-
* */
|
|
50
33
|
setLogFormatter(fn) {
|
|
51
|
-
if (typeof fn !==
|
|
52
|
-
throw new this.leyyo.developerError(
|
|
34
|
+
if (typeof fn !== "function") {
|
|
35
|
+
throw new this.leyyo.developerError("Invalid log formatter", testCase(FQN, 200), where);
|
|
53
36
|
}
|
|
54
37
|
this._logFormatter = fn;
|
|
55
38
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Set deployment styler
|
|
58
|
-
*
|
|
59
|
-
* @param {function} fn - lambda for styler
|
|
60
|
-
* */
|
|
61
39
|
setLogDeploymentStyler(fn) {
|
|
62
|
-
if (typeof fn !==
|
|
63
|
-
throw new this.leyyo.developerError(
|
|
40
|
+
if (typeof fn !== "function") {
|
|
41
|
+
throw new this.leyyo.developerError("Invalid log styler", testCase(FQN, 201), where);
|
|
64
42
|
}
|
|
65
43
|
this._logDeploymentStyler = fn;
|
|
66
|
-
if (process.env[
|
|
44
|
+
if (process.env["NODE_ENV"] !== "local") {
|
|
67
45
|
this._logStyler = this._logDeploymentStyler;
|
|
68
46
|
}
|
|
69
47
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Set local style
|
|
72
|
-
*
|
|
73
|
-
* @param {function} fn - lambda for styler
|
|
74
|
-
* */
|
|
75
48
|
setLogLocalStyler(fn) {
|
|
76
|
-
if (typeof fn !==
|
|
77
|
-
throw new this.leyyo.developerError(
|
|
49
|
+
if (typeof fn !== "function") {
|
|
50
|
+
throw new this.leyyo.developerError("Invalid log local styler", testCase(FQN, 202), where);
|
|
78
51
|
}
|
|
79
52
|
this._logLocalStyler = fn;
|
|
80
|
-
if (process.env[
|
|
53
|
+
if (process.env["NODE_ENV"] === "local") {
|
|
81
54
|
this._logStyler = this._logLocalStyler;
|
|
82
55
|
}
|
|
83
56
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Set local style
|
|
86
|
-
*
|
|
87
|
-
* @param {function} fn - lambda for styler
|
|
88
|
-
* */
|
|
89
57
|
setContextFinder(fn) {
|
|
90
|
-
if (typeof fn !==
|
|
91
|
-
throw new this.leyyo.developerError(
|
|
58
|
+
if (typeof fn !== "function") {
|
|
59
|
+
throw new this.leyyo.developerError("Invalid log local styler", testCase(FQN, 202), where);
|
|
92
60
|
}
|
|
93
61
|
this._contextFinder = fn;
|
|
94
62
|
}
|
|
95
|
-
// endregion setters
|
|
96
|
-
// region private
|
|
97
63
|
_defaults() {
|
|
98
|
-
/**
|
|
99
|
-
* Default log formatter
|
|
100
|
-
*
|
|
101
|
-
* @param {LogItem} item
|
|
102
|
-
* */
|
|
103
64
|
this._logFormatter = (item) => {
|
|
104
65
|
if (item?.ctx) {
|
|
105
66
|
const ctx = item.ctx;
|
|
@@ -110,33 +71,27 @@ export class LogCommon {
|
|
|
110
71
|
}
|
|
111
72
|
item.paramStr = item.params ? secureJson(item.params) : undefined;
|
|
112
73
|
delete item.params;
|
|
113
|
-
if (item.paramStr && [
|
|
74
|
+
if (item.paramStr && ["{}", "[]"].includes(item.paramStr)) {
|
|
114
75
|
delete item.paramStr;
|
|
115
76
|
}
|
|
116
77
|
};
|
|
117
|
-
/**
|
|
118
|
-
* Default log deployment styler (on server)
|
|
119
|
-
*
|
|
120
|
-
* @param {LogItem} item
|
|
121
|
-
* @return {string}
|
|
122
|
-
* */
|
|
123
78
|
this._logDeploymentStyler = (item) => {
|
|
124
79
|
let message = item.now;
|
|
125
80
|
if (item?.ctx) {
|
|
126
|
-
if (item.ctx[
|
|
127
|
-
message += ` [p:${item.ctx[
|
|
81
|
+
if (item.ctx["pid"]) {
|
|
82
|
+
message += ` [p:${item.ctx["pid"]}]`;
|
|
128
83
|
}
|
|
129
84
|
else {
|
|
130
85
|
message += ` [p:]`;
|
|
131
86
|
}
|
|
132
|
-
if (item.ctx[
|
|
133
|
-
message += ` [t:${item.ctx[
|
|
87
|
+
if (item.ctx["tid"]) {
|
|
88
|
+
message += ` [t:${item.ctx["tid"]}]`;
|
|
134
89
|
}
|
|
135
90
|
else {
|
|
136
91
|
message += ` [t:]`;
|
|
137
92
|
}
|
|
138
|
-
if (item.ctx[
|
|
139
|
-
message += ` [c:${item.ctx[
|
|
93
|
+
if (item.ctx["cid"]) {
|
|
94
|
+
message += ` [c:${item.ctx["cid"]}]`;
|
|
140
95
|
}
|
|
141
96
|
else {
|
|
142
97
|
message += ` [c:]`;
|
|
@@ -148,28 +103,22 @@ export class LogCommon {
|
|
|
148
103
|
else {
|
|
149
104
|
message += ` [w:]`;
|
|
150
105
|
}
|
|
151
|
-
message +=
|
|
152
|
-
return message + (item.paramStr ?
|
|
106
|
+
message += " " + item.message;
|
|
107
|
+
return message + (item.paramStr ? " ~^~ " + item.paramStr : "");
|
|
153
108
|
};
|
|
154
|
-
/**
|
|
155
|
-
* Default log locale styler (on local computer)
|
|
156
|
-
*
|
|
157
|
-
* @param {LogItem} item
|
|
158
|
-
* @return {string}
|
|
159
|
-
* */
|
|
160
109
|
this._logLocalStyler = (item) => {
|
|
161
110
|
const { bold, end, param } = this._localColor;
|
|
162
111
|
const [isBold, regular, light] = this._localColor.levels[item.level] ?? this._localColor.levels.debug;
|
|
163
112
|
let message = item.now.substring(10, 11) + ` ${param}[p:${process.pid}]${end}`;
|
|
164
113
|
if (item?.ctx) {
|
|
165
|
-
if (item.ctx[
|
|
166
|
-
message += ` ${regular}[t:${item.ctx[
|
|
114
|
+
if (item.ctx["tid"]) {
|
|
115
|
+
message += ` ${regular}[t:${item.ctx["tid"]}]`;
|
|
167
116
|
}
|
|
168
117
|
else {
|
|
169
118
|
message += ` ${param}[t:]`;
|
|
170
119
|
}
|
|
171
|
-
if (item.ctx[
|
|
172
|
-
message += ` ${light}[c:${item.ctx[
|
|
120
|
+
if (item.ctx["cid"]) {
|
|
121
|
+
message += ` ${light}[c:${item.ctx["cid"]}]`;
|
|
173
122
|
}
|
|
174
123
|
else {
|
|
175
124
|
message += ` ${param}[c:]`;
|
|
@@ -181,44 +130,30 @@ export class LogCommon {
|
|
|
181
130
|
else {
|
|
182
131
|
message += ` ${param}[${emptyWhere}]`;
|
|
183
132
|
}
|
|
184
|
-
message += ` ${isBold ? bold :
|
|
185
|
-
return message + (item.paramStr ? ` ~^~ ${param}${item.paramStr}${end}` :
|
|
133
|
+
message += ` ${isBold ? bold : ""}${light}${item.message}${end}`;
|
|
134
|
+
return message + (item.paramStr ? ` ~^~ ${param}${item.paramStr}${end}` : "");
|
|
186
135
|
};
|
|
187
|
-
|
|
188
|
-
* Set current styler by environment
|
|
189
|
-
* */
|
|
190
|
-
if (process.env['NODE_ENV'] === 'local') {
|
|
136
|
+
if (process.env["NODE_ENV"] === "local") {
|
|
191
137
|
this._logStyler = this._logLocalStyler;
|
|
192
138
|
}
|
|
193
139
|
else {
|
|
194
140
|
this._logStyler = this._logDeploymentStyler;
|
|
195
141
|
}
|
|
196
142
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Build short style of logger name
|
|
199
|
-
*
|
|
200
|
-
* @param {string} where - original logger name
|
|
201
|
-
* @param {string} - short style
|
|
202
|
-
* */
|
|
203
143
|
_shortenWhere(where) {
|
|
204
144
|
if (!where) {
|
|
205
145
|
return undefined;
|
|
206
146
|
}
|
|
207
|
-
if (!where.includes(
|
|
147
|
+
if (!where.includes(".")) {
|
|
208
148
|
return where;
|
|
209
149
|
}
|
|
210
|
-
const parts = where.split(
|
|
150
|
+
const parts = where.split(".");
|
|
211
151
|
where = parts.pop();
|
|
212
152
|
if (parts.length > 0) {
|
|
213
|
-
where = parts.map(w => w.slice(0, 1)).join(
|
|
153
|
+
where = parts.map((w) => w.slice(0, 1)).join(".") + "." + where;
|
|
214
154
|
}
|
|
215
155
|
return where;
|
|
216
156
|
}
|
|
217
|
-
/**
|
|
218
|
-
* Log consumer
|
|
219
|
-
*
|
|
220
|
-
* @param {LogItem} item
|
|
221
|
-
* */
|
|
222
157
|
_consumeLog(item) {
|
|
223
158
|
if (!isObj(item)) {
|
|
224
159
|
return;
|
|
@@ -227,46 +162,31 @@ export class LogCommon {
|
|
|
227
162
|
try {
|
|
228
163
|
this._logFormatter(item);
|
|
229
164
|
}
|
|
230
|
-
catch (
|
|
165
|
+
catch (_e) {
|
|
231
166
|
}
|
|
232
167
|
let message;
|
|
233
168
|
try {
|
|
234
169
|
message = this._logStyler(item);
|
|
235
170
|
}
|
|
236
|
-
catch (
|
|
171
|
+
catch (_e) {
|
|
237
172
|
}
|
|
238
|
-
if (typeof message !==
|
|
239
|
-
message = `${item?.now} - ${typeof item.message ===
|
|
173
|
+
if (typeof message !== "string") {
|
|
174
|
+
message = `${item?.now} - ${typeof item.message === "string" ? item.message : secureJson(item.message)}`;
|
|
240
175
|
if (item.params) {
|
|
241
176
|
message += ` ~^~ ${secureJson(item.params)}`;
|
|
242
177
|
}
|
|
243
178
|
}
|
|
244
179
|
console[item.level](message);
|
|
245
180
|
}
|
|
246
|
-
/**
|
|
247
|
-
* Generate random logger name
|
|
248
|
-
*
|
|
249
|
-
* @return {string}
|
|
250
|
-
* */
|
|
251
181
|
_randomLoggerName() {
|
|
252
|
-
return this._checkLoggerName(
|
|
182
|
+
return this._checkLoggerName("Logger", Math.floor(Math.random() * 1000));
|
|
253
183
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Check logger name's uniqueness, and loop till unique name
|
|
256
|
-
*
|
|
257
|
-
* @param {string} name - base name
|
|
258
|
-
* @param {number} index - try count
|
|
259
|
-
* @return {string}
|
|
260
|
-
* */
|
|
261
184
|
_checkLoggerName(name, index) {
|
|
262
185
|
if (this._loggers.has(name)) {
|
|
263
186
|
return this._checkLoggerName(name, index + 1);
|
|
264
187
|
}
|
|
265
|
-
return name + (index === 0) ?
|
|
188
|
+
return name + (index === 0) ? "" : `(#${index})`;
|
|
266
189
|
}
|
|
267
|
-
// endregion private
|
|
268
|
-
// region public
|
|
269
|
-
/** @inheritDoc */
|
|
270
190
|
of(value) {
|
|
271
191
|
let name;
|
|
272
192
|
let fqn;
|
|
@@ -289,25 +209,20 @@ export class LogCommon {
|
|
|
289
209
|
}
|
|
290
210
|
const ins = new this.leyyo.loggerInstance(name);
|
|
291
211
|
if (!fqn) {
|
|
292
|
-
onFqnSet(value, f => ins.$secure.$refreshName(f));
|
|
212
|
+
onFqnSet(value, (f) => ins.$secure.$refreshName(f));
|
|
293
213
|
}
|
|
294
214
|
this._loggers.set(name, ins);
|
|
295
215
|
return ins;
|
|
296
216
|
}
|
|
297
|
-
/** @inheritDoc */
|
|
298
217
|
initConsume() {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (typeof v === 'function') {
|
|
218
|
+
this.leyyo.eventCommon.listen("context:set-finder", (v) => {
|
|
219
|
+
if (typeof v === "function") {
|
|
302
220
|
this._contextFinder = v;
|
|
303
221
|
}
|
|
304
222
|
});
|
|
305
|
-
|
|
306
|
-
this.
|
|
307
|
-
this.initConsume = () => {
|
|
308
|
-
};
|
|
223
|
+
this.leyyo.eventCommon.listen("log", (v) => this._consumeLog(v));
|
|
224
|
+
this.initConsume = () => { };
|
|
309
225
|
}
|
|
310
|
-
/** @inheritDoc */
|
|
311
226
|
emitLog(level, where, message, params) {
|
|
312
227
|
const item = {
|
|
313
228
|
level,
|
|
@@ -324,25 +239,25 @@ export class LogCommon {
|
|
|
324
239
|
}
|
|
325
240
|
err[KEY_LOG_ALREADY] = true;
|
|
326
241
|
}
|
|
327
|
-
catch (
|
|
242
|
+
catch (_e) {
|
|
328
243
|
}
|
|
329
244
|
item.message = this.leyyo.errorCommon.text(message);
|
|
330
245
|
item.params = this.leyyo.errorCommon.toJsonBasic(message, params);
|
|
331
246
|
}
|
|
332
247
|
else {
|
|
333
|
-
if (typeof message !==
|
|
248
|
+
if (typeof message !== "string") {
|
|
334
249
|
if (isEmpty(message)) {
|
|
335
|
-
message =
|
|
250
|
+
message = "??";
|
|
336
251
|
}
|
|
337
252
|
else {
|
|
338
|
-
if (typeof message ===
|
|
253
|
+
if (typeof message === "object") {
|
|
339
254
|
try {
|
|
340
255
|
if (message[KEY_LOG_ALREADY]) {
|
|
341
256
|
return;
|
|
342
257
|
}
|
|
343
258
|
message[KEY_LOG_ALREADY] = true;
|
|
344
259
|
}
|
|
345
|
-
catch (
|
|
260
|
+
catch (_e) {
|
|
346
261
|
}
|
|
347
262
|
}
|
|
348
263
|
message = secureJson(message);
|
|
@@ -353,7 +268,7 @@ export class LogCommon {
|
|
|
353
268
|
}
|
|
354
269
|
if (!item.where && params?.where) {
|
|
355
270
|
try {
|
|
356
|
-
if (typeof params.where ===
|
|
271
|
+
if (typeof params.where === "string") {
|
|
357
272
|
item.where = params.where;
|
|
358
273
|
delete params.where;
|
|
359
274
|
}
|
|
@@ -363,16 +278,16 @@ export class LogCommon {
|
|
|
363
278
|
params.where.delete(item.where);
|
|
364
279
|
}
|
|
365
280
|
}
|
|
366
|
-
catch (
|
|
281
|
+
catch (_e) {
|
|
367
282
|
}
|
|
368
283
|
}
|
|
369
284
|
if (this._contextFinder) {
|
|
370
285
|
try {
|
|
371
286
|
item.ctx = this._contextFinder(item.params?.req);
|
|
372
287
|
}
|
|
373
|
-
catch (
|
|
288
|
+
catch (_e) {
|
|
374
289
|
}
|
|
375
290
|
}
|
|
376
|
-
this.leyyo.eventCommon.emit(
|
|
291
|
+
this.leyyo.eventCommon.emit("log", item);
|
|
377
292
|
}
|
|
378
293
|
}
|
|
@@ -4,222 +4,34 @@ import { LeyyoLike } from "../base/index.js";
|
|
|
4
4
|
export declare class RepoCommon implements RepoCommonLike {
|
|
5
5
|
private leyyo;
|
|
6
6
|
private static _created;
|
|
7
|
-
/**
|
|
8
|
-
* Internal items which stores arrays
|
|
9
|
-
* */
|
|
10
7
|
private _arrayItems;
|
|
11
|
-
/**
|
|
12
|
-
* Internal array volatile repo which could be cleared after lifecycle run
|
|
13
|
-
* */
|
|
14
8
|
private _arrayVolatiles;
|
|
15
|
-
/**
|
|
16
|
-
* Internal items which stores lists
|
|
17
|
-
* */
|
|
18
9
|
private _listItems;
|
|
19
|
-
/**
|
|
20
|
-
* Internal list volatiles repo which could be cleared after lifecycle run
|
|
21
|
-
* */
|
|
22
10
|
private _listVolatiles;
|
|
23
|
-
/**
|
|
24
|
-
* Internal items which stores maps
|
|
25
|
-
* */
|
|
26
11
|
private _mapItems;
|
|
27
|
-
/**
|
|
28
|
-
* Internal map volatile repo which could be cleared after lifecycle run
|
|
29
|
-
* */
|
|
30
12
|
private _mapVolatiles;
|
|
31
|
-
/**
|
|
32
|
-
* Internal items which stores sets
|
|
33
|
-
* */
|
|
34
13
|
private _setItems;
|
|
35
|
-
/**
|
|
36
|
-
* Internal set volatiles repo which could be cleared after lifecycle run
|
|
37
|
-
* */
|
|
38
14
|
private _setVolatiles;
|
|
39
15
|
constructor(leyyo: LeyyoLike);
|
|
40
|
-
/**
|
|
41
|
-
* Create new array
|
|
42
|
-
*
|
|
43
|
-
* @param {string} name - name of collection
|
|
44
|
-
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
45
|
-
* @return {Array<any>}
|
|
46
|
-
* */
|
|
47
16
|
newArray<V>(name: string, volatile?: boolean): Array<V>;
|
|
48
|
-
/**
|
|
49
|
-
* Remove array by given key
|
|
50
|
-
*
|
|
51
|
-
* @param {symbol} key - key of collection
|
|
52
|
-
* @return {number}
|
|
53
|
-
*
|
|
54
|
-
* Return possibilities:
|
|
55
|
-
* - `-2`: key is not valid symbol
|
|
56
|
-
* - `-1`: key does not exist
|
|
57
|
-
* - `>= 0`: length of removed items in collection
|
|
58
|
-
* */
|
|
59
17
|
removeArray(key: symbol): number;
|
|
60
|
-
/**
|
|
61
|
-
* Clear array by given key
|
|
62
|
-
*
|
|
63
|
-
* @param {symbol} key - key of collection
|
|
64
|
-
* @return {number}
|
|
65
|
-
*
|
|
66
|
-
* Return possibilities:
|
|
67
|
-
* - `-2`: key is not valid symbol
|
|
68
|
-
* - `-1`: key does not exist
|
|
69
|
-
* - `>= 0`: length of cleared items in collection
|
|
70
|
-
* */
|
|
71
18
|
clearArray(key: symbol): number;
|
|
72
|
-
/**
|
|
73
|
-
* List all array keys
|
|
74
|
-
*
|
|
75
|
-
* @return {Array<symbol>}
|
|
76
|
-
* */
|
|
77
19
|
listArrays(): Array<symbol>;
|
|
78
|
-
/**
|
|
79
|
-
* Print all arrays
|
|
80
|
-
*
|
|
81
|
-
* @return {Record} - as {key: length of collection}
|
|
82
|
-
*
|
|
83
|
-
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
84
|
-
* */
|
|
85
20
|
printArrays(): Record<string, number>;
|
|
86
|
-
/**
|
|
87
|
-
* Create new list
|
|
88
|
-
*
|
|
89
|
-
* @param {string} name - name of collection
|
|
90
|
-
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
91
|
-
* @return {List<any>}
|
|
92
|
-
* */
|
|
93
21
|
newList<V>(name: string, volatile?: boolean): List<V>;
|
|
94
|
-
/**
|
|
95
|
-
* Remove list by given key
|
|
96
|
-
*
|
|
97
|
-
* @param {symbol} key - key of collection
|
|
98
|
-
* @return {number}
|
|
99
|
-
*
|
|
100
|
-
* Return possibilities:
|
|
101
|
-
* - `-2`: key is not valid symbol
|
|
102
|
-
* - `-1`: key does not exist
|
|
103
|
-
* - `>= 0`: length of removed items in collection
|
|
104
|
-
* */
|
|
105
22
|
removeList(key: symbol): number;
|
|
106
|
-
/**
|
|
107
|
-
* Clear list by given key
|
|
108
|
-
*
|
|
109
|
-
* @param {symbol} key - key of collection
|
|
110
|
-
* @return {number}
|
|
111
|
-
*
|
|
112
|
-
* Return possibilities:
|
|
113
|
-
* - `-2`: key is not valid symbol
|
|
114
|
-
* - `-1`: key does not exist
|
|
115
|
-
* - `>= 0`: length of cleared items in collection
|
|
116
|
-
* */
|
|
117
23
|
clearList(key: symbol): number;
|
|
118
|
-
/**
|
|
119
|
-
* List all list keys
|
|
120
|
-
*
|
|
121
|
-
* @return {Array<symbol>}
|
|
122
|
-
* */
|
|
123
24
|
listLists(): Array<symbol>;
|
|
124
|
-
/**
|
|
125
|
-
* Print all lists
|
|
126
|
-
*
|
|
127
|
-
* @return {Record} - as {key: length of collection}
|
|
128
|
-
*
|
|
129
|
-
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
130
|
-
* */
|
|
131
25
|
printLists(): Record<string, number>;
|
|
132
|
-
/**
|
|
133
|
-
* Create new map
|
|
134
|
-
*
|
|
135
|
-
* @param {string} name - name of collection
|
|
136
|
-
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
137
|
-
* @return {Map<any, any>}
|
|
138
|
-
* */
|
|
139
26
|
newMap<K, V>(name: string, volatile?: boolean): Map<K, V>;
|
|
140
|
-
/**
|
|
141
|
-
* Remove map by given key
|
|
142
|
-
*
|
|
143
|
-
* @param {symbol} key - key of collection
|
|
144
|
-
* @return {number}
|
|
145
|
-
*
|
|
146
|
-
* Return possibilities:
|
|
147
|
-
* - `-2`: key is not valid symbol
|
|
148
|
-
* - `-1`: key does not exist
|
|
149
|
-
* - `>= 0`: length of removed items in collection
|
|
150
|
-
* */
|
|
151
27
|
removeMap(key: symbol): number;
|
|
152
|
-
/**
|
|
153
|
-
* Clear map by given key
|
|
154
|
-
*
|
|
155
|
-
* @param {symbol} key - key of collection
|
|
156
|
-
* @return {number}
|
|
157
|
-
*
|
|
158
|
-
* Return possibilities:
|
|
159
|
-
* - `-2`: key is not valid symbol
|
|
160
|
-
* - `-1`: key does not exist
|
|
161
|
-
* - `>= 0`: length of cleared items in collection
|
|
162
|
-
* */
|
|
163
28
|
clearMap(key: symbol): number;
|
|
164
|
-
/**
|
|
165
|
-
* List all map keys
|
|
166
|
-
*
|
|
167
|
-
* @return {Array<symbol>}
|
|
168
|
-
* */
|
|
169
29
|
listMaps(): Array<symbol>;
|
|
170
|
-
/**
|
|
171
|
-
* Print all maps
|
|
172
|
-
*
|
|
173
|
-
* @return {Record} - as {key: length of collection}
|
|
174
|
-
*
|
|
175
|
-
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
176
|
-
* */
|
|
177
30
|
printMaps(): Record<string, number>;
|
|
178
|
-
/**
|
|
179
|
-
* Create new set
|
|
180
|
-
*
|
|
181
|
-
* @param {string} name - name of collection
|
|
182
|
-
* @param {boolean} volatile - if yes: it will be removed after lifecycle run
|
|
183
|
-
* @return {Set<any>}
|
|
184
|
-
* */
|
|
185
31
|
newSet<V>(name: string, volatile?: boolean): Set<V>;
|
|
186
|
-
/**
|
|
187
|
-
* Remove set by given key
|
|
188
|
-
*
|
|
189
|
-
* @param {symbol} key - key of collection
|
|
190
|
-
* @return {number}
|
|
191
|
-
*
|
|
192
|
-
* Return possibilities:
|
|
193
|
-
* - `-2`: key is not valid symbol
|
|
194
|
-
* - `-1`: key does not exist
|
|
195
|
-
* - `>= 0`: length of removed items in collection
|
|
196
|
-
* */
|
|
197
32
|
removeSet(key: symbol): number;
|
|
198
|
-
/**
|
|
199
|
-
* Clear set by given key
|
|
200
|
-
*
|
|
201
|
-
* @param {symbol} key - key of collection
|
|
202
|
-
* @return {number}
|
|
203
|
-
*
|
|
204
|
-
* Return possibilities:
|
|
205
|
-
* - `-2`: key is not valid symbol
|
|
206
|
-
* - `-1`: key does not exist
|
|
207
|
-
* - `>= 0`: length of cleared items in collection
|
|
208
|
-
* */
|
|
209
33
|
clearSet(key: symbol): number;
|
|
210
|
-
/**
|
|
211
|
-
* List all set keys
|
|
212
|
-
*
|
|
213
|
-
* @return {Array<symbol>}
|
|
214
|
-
* */
|
|
215
34
|
listSets(): Array<symbol>;
|
|
216
|
-
/**
|
|
217
|
-
* Print all sets
|
|
218
|
-
*
|
|
219
|
-
* @return {Record} - as {key: length of collection}
|
|
220
|
-
*
|
|
221
|
-
* Note: if stringified symbol is duplicated, add index postfix with `#` symbol
|
|
222
|
-
* */
|
|
223
35
|
printSets(): Record<string, number>;
|
|
224
36
|
init(): void;
|
|
225
37
|
}
|