@adapt-arch/utiliti-es 0.1.0 → 0.2.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/README.md +1 -0
- package/dist/bundle/utiliti-es.cjs +1 -1
- package/dist/bundle/utiliti-es.iife.js +1 -1
- package/dist/bundle/utiliti-es.js +258 -172
- package/dist/bundle/utiliti-es.umd.cjs +1 -1
- package/dist/pubsub/index.d.ts +2 -1
- package/dist/pubsub/index.js +2 -1
- package/dist/pubsub/plugins/broadcastChannelPlugin.d.ts +29 -0
- package/dist/pubsub/plugins/broadcastChannelPlugin.js +55 -0
- package/dist/pubsub/plugins/index.d.ts +2 -0
- package/dist/pubsub/plugins/index.js +2 -0
- package/dist/pubsub/plugins/loggerPlugin.d.ts +18 -0
- package/dist/pubsub/plugins/loggerPlugin.js +25 -0
- package/dist/pubsub/pubsub.d.ts +45 -0
- package/dist/pubsub/pubsub.js +45 -5
- package/package.json +14 -11
- package/dist/bundle/mockServiceWorker.js +0 -284
- package/dist/mocks/logReporterHandlers.d.ts +0 -1
- package/dist/mocks/logReporterHandlers.js +0 -27
|
@@ -1,175 +1,232 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var p = (r, s, e) => s in r ? g(r, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[s] = e;
|
|
3
|
+
var i = (r, s, e) => (p(r, typeof s != "symbol" ? s + "" : s, e), e);
|
|
4
|
+
class m {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
constructor(s) {
|
|
9
|
+
i(this, "_subscriptions", /* @__PURE__ */ new Map());
|
|
10
|
+
i(this, "_options");
|
|
11
|
+
var e;
|
|
12
|
+
if (this._options = s, (e = this._options) != null && e.plugins)
|
|
13
|
+
for (const t of this._options.plugins)
|
|
14
|
+
t.init && t.init(this);
|
|
7
15
|
}
|
|
8
16
|
/** @inheritdoc */
|
|
9
|
-
publish(
|
|
10
|
-
|
|
17
|
+
publish(s, e) {
|
|
18
|
+
var a;
|
|
19
|
+
const t = {
|
|
20
|
+
topic: s,
|
|
21
|
+
message: e
|
|
22
|
+
};
|
|
23
|
+
if ((a = this._options) != null && a.plugins)
|
|
24
|
+
for (const l of this._options.plugins)
|
|
25
|
+
l.onPublish && l.onPublish(t);
|
|
26
|
+
if (!t.topic)
|
|
11
27
|
throw new Error("Invalid topic.");
|
|
12
|
-
if (!
|
|
28
|
+
if (!t.message)
|
|
13
29
|
throw new Error("Invalid message.");
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
for (const
|
|
17
|
-
const
|
|
18
|
-
setTimeout(() =>
|
|
30
|
+
const n = this._subscriptions.get(t.topic);
|
|
31
|
+
if (n)
|
|
32
|
+
for (const l of n.values()) {
|
|
33
|
+
const h = structuredClone(t.topic), u = structuredClone(t.message);
|
|
34
|
+
setTimeout(() => l(h, u), 0);
|
|
19
35
|
}
|
|
20
36
|
}
|
|
21
37
|
/** @inheritdoc */
|
|
22
|
-
subscribe(
|
|
23
|
-
if (!e)
|
|
24
|
-
throw new Error("Invalid topic.");
|
|
38
|
+
subscribe(s, e) {
|
|
25
39
|
if (!s)
|
|
40
|
+
throw new Error("Invalid topic.");
|
|
41
|
+
if (!e)
|
|
26
42
|
throw new Error("Invalid handler.");
|
|
27
|
-
let
|
|
28
|
-
|
|
43
|
+
let t = this._subscriptions.get(s);
|
|
44
|
+
t || (t = /* @__PURE__ */ new Map(), this._subscriptions.set(structuredClone(s), t));
|
|
29
45
|
const n = `sub-${Date.now()}`;
|
|
30
|
-
return
|
|
46
|
+
return t.set(n, e), n;
|
|
31
47
|
}
|
|
32
48
|
/** @inheritdoc */
|
|
33
|
-
unsubscribe(
|
|
34
|
-
if (
|
|
35
|
-
for (const
|
|
36
|
-
if (
|
|
49
|
+
unsubscribe(s) {
|
|
50
|
+
if (s) {
|
|
51
|
+
for (const e of this._subscriptions.values())
|
|
52
|
+
if (e.delete(s))
|
|
37
53
|
return;
|
|
38
54
|
}
|
|
39
55
|
}
|
|
56
|
+
[Symbol.dispose]() {
|
|
57
|
+
var s;
|
|
58
|
+
if (this._subscriptions.clear(), (s = this._options) != null && s.plugins)
|
|
59
|
+
for (const e of this._options.plugins) {
|
|
60
|
+
const t = e[Symbol.dispose];
|
|
61
|
+
t && t.call(e);
|
|
62
|
+
}
|
|
63
|
+
return Promise.resolve();
|
|
64
|
+
}
|
|
40
65
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
class f {
|
|
67
|
+
/**
|
|
68
|
+
* Constructor.
|
|
69
|
+
*
|
|
70
|
+
* @param {Options} options The options.
|
|
71
|
+
*/
|
|
72
|
+
constructor(s) {
|
|
73
|
+
i(this, "_options");
|
|
74
|
+
i(this, "_channel");
|
|
75
|
+
i(this, "_eventListeners", null);
|
|
76
|
+
i(this, "_broadcastEnabled", !0);
|
|
77
|
+
this._options = s, this._channel = new BroadcastChannel(this._options.channelName);
|
|
78
|
+
}
|
|
79
|
+
/** @inheritdoc */
|
|
80
|
+
init(s) {
|
|
81
|
+
this._eventListeners || (this._eventListeners = (e) => {
|
|
82
|
+
const t = e.data;
|
|
83
|
+
if (!(!t.topic || !t.message))
|
|
84
|
+
try {
|
|
85
|
+
this._broadcastEnabled = !1, s.publish(t.topic, t.message);
|
|
86
|
+
} finally {
|
|
87
|
+
this._broadcastEnabled = !0;
|
|
88
|
+
}
|
|
89
|
+
}, this._channel.addEventListener("message", this._eventListeners));
|
|
90
|
+
}
|
|
91
|
+
/** @inheritdoc */
|
|
92
|
+
onPublish(s) {
|
|
93
|
+
if (!this._broadcastEnabled || !s.topic || !s.message)
|
|
94
|
+
return;
|
|
95
|
+
const e = {
|
|
96
|
+
topic: s.topic,
|
|
97
|
+
message: s.message
|
|
98
|
+
};
|
|
99
|
+
this._channel.postMessage(e);
|
|
100
|
+
}
|
|
101
|
+
[Symbol.dispose]() {
|
|
102
|
+
this._eventListeners && this._channel.removeEventListener("message", this._eventListeners), this._channel.close();
|
|
103
|
+
}
|
|
47
104
|
}
|
|
48
|
-
class
|
|
105
|
+
class d {
|
|
49
106
|
/**
|
|
50
107
|
* Constructor.
|
|
51
108
|
*
|
|
52
109
|
* @param {ExtraParams} values The values to add to the log.
|
|
53
110
|
* @param {boolean} overrideExisting Override a value if it already exists.
|
|
54
111
|
*/
|
|
55
|
-
constructor(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this._values =
|
|
112
|
+
constructor(s, e) {
|
|
113
|
+
i(this, "_values");
|
|
114
|
+
i(this, "_overrideExisting");
|
|
115
|
+
this._values = s, this._overrideExisting = e;
|
|
59
116
|
}
|
|
60
117
|
/**
|
|
61
118
|
* @inheritdoc
|
|
62
119
|
*/
|
|
63
|
-
enrich(
|
|
120
|
+
enrich(s) {
|
|
64
121
|
if (!this._values)
|
|
65
122
|
return;
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
for (const
|
|
69
|
-
|
|
123
|
+
s.extraParams = s.extraParams || {};
|
|
124
|
+
const e = Object.keys(s.extraParams);
|
|
125
|
+
for (const t in this._values)
|
|
126
|
+
e.indexOf(t) !== -1 && !this._overrideExisting || (s.extraParams[t] = this._values[t]);
|
|
70
127
|
}
|
|
71
128
|
}
|
|
72
|
-
class
|
|
129
|
+
class b {
|
|
73
130
|
/**
|
|
74
131
|
* Constructor.
|
|
75
132
|
*
|
|
76
133
|
* @param {DynamicValuesFunction} valuesFunction The values to add to the log.
|
|
77
134
|
* @param {boolean} overrideExisting Override a value if it already exists.
|
|
78
135
|
*/
|
|
79
|
-
constructor(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this._valuesFn =
|
|
136
|
+
constructor(s, e) {
|
|
137
|
+
i(this, "_valuesFn");
|
|
138
|
+
i(this, "_overrideExisting");
|
|
139
|
+
this._valuesFn = s, this._overrideExisting = e;
|
|
83
140
|
}
|
|
84
141
|
/**
|
|
85
142
|
* @inheritdoc
|
|
86
143
|
*/
|
|
87
|
-
enrich(
|
|
88
|
-
const
|
|
89
|
-
if (!
|
|
144
|
+
enrich(s) {
|
|
145
|
+
const e = typeof this._valuesFn == "function" ? this._valuesFn() : void 0;
|
|
146
|
+
if (!e)
|
|
90
147
|
return;
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
for (const n in
|
|
94
|
-
|
|
148
|
+
s.extraParams = s.extraParams || {};
|
|
149
|
+
const t = Object.keys(s.extraParams);
|
|
150
|
+
for (const n in e)
|
|
151
|
+
t.indexOf(n) !== -1 && !this._overrideExisting || (s.extraParams[n] = e[n]);
|
|
95
152
|
}
|
|
96
153
|
}
|
|
97
154
|
var o;
|
|
98
|
-
(function(
|
|
99
|
-
|
|
155
|
+
(function(r) {
|
|
156
|
+
r[r.Trace = 0] = "Trace", r[r.Debug = 1] = "Debug", r[r.Information = 2] = "Information", r[r.Warning = 3] = "Warning", r[r.Error = 4] = "Error", r[r.Critical = 5] = "Critical", r[r.None = 6] = "None";
|
|
100
157
|
})(o || (o = {}));
|
|
101
158
|
class c {
|
|
102
159
|
constructor() {
|
|
103
160
|
/**
|
|
104
161
|
* The timestamp of the log message.
|
|
105
162
|
*/
|
|
106
|
-
|
|
163
|
+
i(this, "timestamp", (/* @__PURE__ */ new Date()).getTime());
|
|
107
164
|
/**
|
|
108
165
|
* The level of the log message.
|
|
109
166
|
*/
|
|
110
|
-
|
|
167
|
+
i(this, "level", o.None);
|
|
111
168
|
/**
|
|
112
169
|
* The name of the logger.
|
|
113
170
|
*/
|
|
114
|
-
|
|
171
|
+
i(this, "name", "");
|
|
115
172
|
/**
|
|
116
173
|
* The message to log.
|
|
117
174
|
*/
|
|
118
|
-
|
|
175
|
+
i(this, "message", "");
|
|
119
176
|
/**
|
|
120
177
|
* The error message.
|
|
121
178
|
*/
|
|
122
|
-
|
|
179
|
+
i(this, "errorMessage");
|
|
123
180
|
/**
|
|
124
181
|
* The stack trace of the error.
|
|
125
182
|
*/
|
|
126
|
-
|
|
183
|
+
i(this, "stackTrace");
|
|
127
184
|
/**
|
|
128
185
|
* Any extra parameters to log.
|
|
129
186
|
*/
|
|
130
|
-
|
|
187
|
+
i(this, "extraParams");
|
|
131
188
|
}
|
|
132
189
|
}
|
|
133
|
-
class
|
|
190
|
+
class v {
|
|
134
191
|
/**
|
|
135
192
|
* Constructor.
|
|
136
193
|
*
|
|
137
194
|
* @param {Console} console The current console reference.
|
|
138
195
|
*/
|
|
139
|
-
constructor(
|
|
140
|
-
|
|
141
|
-
this._console =
|
|
196
|
+
constructor(s) {
|
|
197
|
+
i(this, "_console");
|
|
198
|
+
this._console = s;
|
|
142
199
|
}
|
|
143
200
|
/**
|
|
144
201
|
* @inheritdoc
|
|
145
202
|
*/
|
|
146
|
-
register(
|
|
147
|
-
let
|
|
203
|
+
register(s) {
|
|
204
|
+
let e;
|
|
148
205
|
if (this._console)
|
|
149
|
-
switch (
|
|
206
|
+
switch (s.level) {
|
|
150
207
|
case o.Trace:
|
|
151
|
-
|
|
208
|
+
e = this._console.trace || this._console.log;
|
|
152
209
|
break;
|
|
153
210
|
case o.Debug:
|
|
154
|
-
|
|
211
|
+
e = this._console.debug || this._console.log;
|
|
155
212
|
break;
|
|
156
213
|
case o.Information:
|
|
157
|
-
|
|
214
|
+
e = this._console.info || this._console.log;
|
|
158
215
|
break;
|
|
159
216
|
case o.Warning:
|
|
160
|
-
|
|
217
|
+
e = this._console.warn || this._console.log;
|
|
161
218
|
break;
|
|
162
219
|
case o.Error:
|
|
163
|
-
|
|
220
|
+
e = this._console.error || this._console.log;
|
|
164
221
|
break;
|
|
165
222
|
case o.Critical:
|
|
166
|
-
|
|
223
|
+
e = this._console.error || this._console.log;
|
|
167
224
|
break;
|
|
168
225
|
default:
|
|
169
|
-
|
|
226
|
+
e = null;
|
|
170
227
|
break;
|
|
171
228
|
}
|
|
172
|
-
typeof
|
|
229
|
+
typeof e == "function" && e.call(this._console, s.message, s);
|
|
173
230
|
}
|
|
174
231
|
/**
|
|
175
232
|
* @inheritdoc
|
|
@@ -178,46 +235,46 @@ class d {
|
|
|
178
235
|
return Promise.resolve();
|
|
179
236
|
}
|
|
180
237
|
}
|
|
181
|
-
class
|
|
238
|
+
class w {
|
|
182
239
|
constructor() {
|
|
183
240
|
/**
|
|
184
241
|
* Endpoint that receives the logs.
|
|
185
242
|
*/
|
|
186
|
-
|
|
243
|
+
i(this, "endpoint", "");
|
|
187
244
|
/**
|
|
188
245
|
* HTTP verb used when calling the endpoint.
|
|
189
246
|
*/
|
|
190
|
-
|
|
247
|
+
i(this, "verb", "POST");
|
|
191
248
|
/**
|
|
192
249
|
* The number of items to send in a batch.
|
|
193
250
|
*/
|
|
194
|
-
|
|
251
|
+
i(this, "batchSize", 20);
|
|
195
252
|
/**
|
|
196
253
|
* The maximum interval, in milliseconds, to wait for the batch size to be achieved before reporting.
|
|
197
254
|
*/
|
|
198
|
-
|
|
255
|
+
i(this, "interval", 2e3);
|
|
199
256
|
/**
|
|
200
257
|
* A function that can be used to transform the request before sending it.
|
|
201
258
|
*/
|
|
202
|
-
|
|
259
|
+
i(this, "requestTransform");
|
|
203
260
|
}
|
|
204
261
|
}
|
|
205
|
-
class
|
|
206
|
-
constructor(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (!
|
|
262
|
+
class y {
|
|
263
|
+
constructor(s) {
|
|
264
|
+
i(this, "_messageQueue");
|
|
265
|
+
i(this, "_options");
|
|
266
|
+
i(this, "_reportActionTimeoutRef");
|
|
267
|
+
i(this, "_reportActionPromise");
|
|
268
|
+
i(this, "_disposed");
|
|
269
|
+
if (!s)
|
|
213
270
|
throw new Error('Argument "options" is required');
|
|
214
|
-
this._messageQueue = [], this._options =
|
|
271
|
+
this._messageQueue = [], this._options = s, this._reportActionTimeoutRef = void 0, this._reportActionPromise = null, this._disposed = !1;
|
|
215
272
|
}
|
|
216
273
|
/**
|
|
217
274
|
* @inheritdoc
|
|
218
275
|
*/
|
|
219
|
-
register(
|
|
220
|
-
this._disposed || (this._messageQueue.push(
|
|
276
|
+
register(s) {
|
|
277
|
+
this._disposed || (this._messageQueue.push(s), this._scheduleNextProcessAction());
|
|
221
278
|
}
|
|
222
279
|
/**
|
|
223
280
|
* @inheritdoc
|
|
@@ -230,36 +287,36 @@ class w {
|
|
|
230
287
|
_scheduleNextProcessAction() {
|
|
231
288
|
if (this._reportActionTimeoutRef)
|
|
232
289
|
return;
|
|
233
|
-
const
|
|
290
|
+
const s = this._messageQueue.length >= this._options.batchSize ? 0 : this._options.interval;
|
|
234
291
|
this._reportActionTimeoutRef = setTimeout(() => {
|
|
235
292
|
this._reportActionPromise = this._processMessages().then(() => {
|
|
236
|
-
const
|
|
237
|
-
this._reportActionTimeoutRef = void 0, clearTimeout(
|
|
293
|
+
const e = this._reportActionTimeoutRef;
|
|
294
|
+
this._reportActionTimeoutRef = void 0, clearTimeout(e), this._reportActionPromise = null, this._scheduleNextProcessAction();
|
|
238
295
|
});
|
|
239
|
-
},
|
|
296
|
+
}, s);
|
|
240
297
|
}
|
|
241
298
|
async _processMessages() {
|
|
242
|
-
let
|
|
299
|
+
let s, e;
|
|
243
300
|
for (; this._messageQueue.length > 0; )
|
|
244
|
-
if (
|
|
245
|
-
this._messageQueue.unshift(...
|
|
301
|
+
if (s = this._messageQueue.splice(0, Math.min(this._messageQueue.length, this._options.batchSize)), e = await this._sendMessagesBatch(s), !e) {
|
|
302
|
+
this._messageQueue.unshift(...s);
|
|
246
303
|
return;
|
|
247
304
|
}
|
|
248
305
|
}
|
|
249
|
-
_sendMessagesBatch(
|
|
250
|
-
return new Promise((
|
|
251
|
-
const
|
|
252
|
-
|
|
306
|
+
_sendMessagesBatch(s) {
|
|
307
|
+
return new Promise((e) => {
|
|
308
|
+
const t = () => {
|
|
309
|
+
e(!1);
|
|
253
310
|
}, n = new XMLHttpRequest();
|
|
254
311
|
n.open(this._options.verb, this._options.endpoint), n.setRequestHeader("Content-Type", "application/json;charset=UTF-8"), this._options.requestTransform && this._options.requestTransform(n), n.onload = function() {
|
|
255
|
-
|
|
256
|
-
}, n.onerror =
|
|
312
|
+
e(this.status >= 200 && this.status < 300);
|
|
313
|
+
}, n.onerror = t, n.onabort = t, n.send(JSON.stringify(s));
|
|
257
314
|
});
|
|
258
315
|
}
|
|
259
316
|
}
|
|
260
|
-
class
|
|
317
|
+
class P {
|
|
261
318
|
constructor() {
|
|
262
|
-
|
|
319
|
+
i(this, "_messages", []);
|
|
263
320
|
}
|
|
264
321
|
get messages() {
|
|
265
322
|
return this._messages.slice();
|
|
@@ -267,8 +324,8 @@ class v {
|
|
|
267
324
|
/**
|
|
268
325
|
* @inheritdoc
|
|
269
326
|
*/
|
|
270
|
-
register(
|
|
271
|
-
this._messages.push(
|
|
327
|
+
register(s) {
|
|
328
|
+
this._messages.push(s);
|
|
272
329
|
}
|
|
273
330
|
/**
|
|
274
331
|
* @inheritdoc
|
|
@@ -277,26 +334,26 @@ class v {
|
|
|
277
334
|
return Promise.resolve();
|
|
278
335
|
}
|
|
279
336
|
}
|
|
280
|
-
class
|
|
281
|
-
constructor(
|
|
282
|
-
|
|
283
|
-
this._reporters =
|
|
337
|
+
class E {
|
|
338
|
+
constructor(s) {
|
|
339
|
+
i(this, "_reporters");
|
|
340
|
+
this._reporters = s || [];
|
|
284
341
|
}
|
|
285
342
|
/**
|
|
286
343
|
* @inheritdoc
|
|
287
344
|
*/
|
|
288
|
-
register(
|
|
289
|
-
for (const
|
|
290
|
-
|
|
345
|
+
register(s) {
|
|
346
|
+
for (const e of this._reporters)
|
|
347
|
+
e.register(s);
|
|
291
348
|
}
|
|
292
349
|
/**
|
|
293
350
|
* @inheritdoc
|
|
294
351
|
*/
|
|
295
352
|
async [Symbol.asyncDispose]() {
|
|
296
|
-
const
|
|
297
|
-
for (const
|
|
298
|
-
|
|
299
|
-
|
|
353
|
+
const s = new Array();
|
|
354
|
+
for (const e of this._reporters)
|
|
355
|
+
s.push(e[Symbol.asyncDispose]());
|
|
356
|
+
s.length && await Promise.all(s);
|
|
300
357
|
}
|
|
301
358
|
}
|
|
302
359
|
class T {
|
|
@@ -305,90 +362,90 @@ class T {
|
|
|
305
362
|
*
|
|
306
363
|
* @param {LoggerOptions} options The logger options.
|
|
307
364
|
*/
|
|
308
|
-
constructor(
|
|
309
|
-
|
|
310
|
-
this._options =
|
|
365
|
+
constructor(s) {
|
|
366
|
+
i(this, "_options");
|
|
367
|
+
this._options = s;
|
|
311
368
|
}
|
|
312
369
|
/**
|
|
313
370
|
* The core logging method.
|
|
314
371
|
*
|
|
315
372
|
* @param {LogMessage} message The message to log.
|
|
316
373
|
*/
|
|
317
|
-
logMessageCore(
|
|
318
|
-
var
|
|
319
|
-
|
|
320
|
-
for (const
|
|
321
|
-
|
|
322
|
-
(
|
|
374
|
+
logMessageCore(s) {
|
|
375
|
+
var e;
|
|
376
|
+
s.name = this._options.name;
|
|
377
|
+
for (const t of this._options.enrichers)
|
|
378
|
+
t.enrich(s);
|
|
379
|
+
(e = this._options.reporter) == null || e.register(s);
|
|
323
380
|
}
|
|
324
381
|
/**
|
|
325
382
|
* @inheritdoc
|
|
326
383
|
*/
|
|
327
384
|
async [Symbol.asyncDispose]() {
|
|
328
|
-
var
|
|
329
|
-
await ((
|
|
385
|
+
var s;
|
|
386
|
+
await ((s = this._options.reporter) == null ? void 0 : s[Symbol.asyncDispose]());
|
|
330
387
|
}
|
|
331
388
|
/**
|
|
332
389
|
* Indicates if the specified level will be logged.
|
|
333
390
|
*
|
|
334
391
|
* @param {LogLevel} level The log level.
|
|
335
392
|
*/
|
|
336
|
-
isEnabled(
|
|
337
|
-
return
|
|
393
|
+
isEnabled(s) {
|
|
394
|
+
return s !== o.None && s >= this._options.minimumLevel;
|
|
338
395
|
}
|
|
339
396
|
/**
|
|
340
397
|
* Log trace.
|
|
341
398
|
*
|
|
342
399
|
* @param msg The message to log.
|
|
343
400
|
*/
|
|
344
|
-
trace(
|
|
345
|
-
const
|
|
346
|
-
|
|
401
|
+
trace(s) {
|
|
402
|
+
const e = new c();
|
|
403
|
+
e.level = o.Trace, e.message = s, this.logMessage(e);
|
|
347
404
|
}
|
|
348
405
|
/**
|
|
349
406
|
* Log debug.
|
|
350
407
|
*
|
|
351
408
|
* @param msg The message to log.
|
|
352
409
|
*/
|
|
353
|
-
debug(
|
|
354
|
-
const
|
|
355
|
-
|
|
410
|
+
debug(s) {
|
|
411
|
+
const e = new c();
|
|
412
|
+
e.level = o.Debug, e.message = s, this.logMessage(e);
|
|
356
413
|
}
|
|
357
414
|
/**
|
|
358
415
|
* Log information.
|
|
359
416
|
*
|
|
360
417
|
* @param msg The message to log.
|
|
361
418
|
*/
|
|
362
|
-
info(
|
|
363
|
-
const
|
|
364
|
-
|
|
419
|
+
info(s) {
|
|
420
|
+
const e = new c();
|
|
421
|
+
e.level = o.Information, e.message = s, this.logMessage(e);
|
|
365
422
|
}
|
|
366
423
|
/**
|
|
367
424
|
* Log warning.
|
|
368
425
|
*
|
|
369
426
|
* @param msg The message to log.
|
|
370
427
|
*/
|
|
371
|
-
warn(
|
|
372
|
-
const
|
|
373
|
-
|
|
428
|
+
warn(s) {
|
|
429
|
+
const e = new c();
|
|
430
|
+
e.level = o.Warning, e.message = s, this.logMessage(e);
|
|
374
431
|
}
|
|
375
432
|
/**
|
|
376
433
|
* Log error.
|
|
377
434
|
*
|
|
378
435
|
* @param msg The message to log.
|
|
379
436
|
*/
|
|
380
|
-
error(
|
|
381
|
-
const
|
|
382
|
-
|
|
437
|
+
error(s) {
|
|
438
|
+
const e = new c();
|
|
439
|
+
e.level = o.Error, e.message = s, this.logMessage(e);
|
|
383
440
|
}
|
|
384
441
|
/**
|
|
385
442
|
* Log error.
|
|
386
443
|
*
|
|
387
444
|
* @param msg The message to log.
|
|
388
445
|
*/
|
|
389
|
-
crit(
|
|
390
|
-
const
|
|
391
|
-
|
|
446
|
+
crit(s) {
|
|
447
|
+
const e = new c();
|
|
448
|
+
e.level = o.Critical, e.message = s, this.logMessage(e);
|
|
392
449
|
}
|
|
393
450
|
/**
|
|
394
451
|
* Log an event.
|
|
@@ -398,18 +455,18 @@ class T {
|
|
|
398
455
|
* @param {Error} e The error associated with the event.
|
|
399
456
|
* @param {ExtraParams} params Extra parameters.
|
|
400
457
|
*/
|
|
401
|
-
log(
|
|
458
|
+
log(s, e, t, n) {
|
|
402
459
|
const a = new c();
|
|
403
|
-
a.level =
|
|
460
|
+
a.level = s, a.message = e, a.errorMessage = t == null ? void 0 : t.message, a.stackTrace = t == null ? void 0 : t.stack, a.extraParams = n, this.logMessage(a);
|
|
404
461
|
}
|
|
405
462
|
/**
|
|
406
463
|
* Log a message.
|
|
407
464
|
*
|
|
408
465
|
* @param {LogMessage} message The message to log.
|
|
409
466
|
*/
|
|
410
|
-
logMessage(
|
|
411
|
-
this.isEnabled(
|
|
412
|
-
this.logMessageCore(
|
|
467
|
+
logMessage(s) {
|
|
468
|
+
this.isEnabled(s.level) && setTimeout(() => {
|
|
469
|
+
this.logMessageCore(s);
|
|
413
470
|
}, 1);
|
|
414
471
|
}
|
|
415
472
|
}
|
|
@@ -418,27 +475,27 @@ class M {
|
|
|
418
475
|
/**
|
|
419
476
|
* The name of the logger.
|
|
420
477
|
*/
|
|
421
|
-
|
|
478
|
+
i(this, "name", "");
|
|
422
479
|
/**
|
|
423
480
|
* The reporter for the messages.
|
|
424
481
|
*/
|
|
425
|
-
|
|
482
|
+
i(this, "reporter", null);
|
|
426
483
|
/**
|
|
427
484
|
* The minimum log level.
|
|
428
485
|
*/
|
|
429
|
-
|
|
486
|
+
i(this, "minimumLevel", o.Warning);
|
|
430
487
|
/**
|
|
431
488
|
* Log enrichers.
|
|
432
489
|
*/
|
|
433
|
-
|
|
490
|
+
i(this, "enrichers", []);
|
|
434
491
|
}
|
|
435
492
|
/**
|
|
436
493
|
* Get the LogLevel from a string value.
|
|
437
494
|
*
|
|
438
495
|
* @param {String} level The log level as string.
|
|
439
496
|
*/
|
|
440
|
-
static getLevel(
|
|
441
|
-
switch ((
|
|
497
|
+
static getLevel(s) {
|
|
498
|
+
switch ((s || "").toUpperCase()) {
|
|
442
499
|
case "TRACE":
|
|
443
500
|
return o.Trace;
|
|
444
501
|
case "DEBUG":
|
|
@@ -458,18 +515,47 @@ class M {
|
|
|
458
515
|
}
|
|
459
516
|
}
|
|
460
517
|
}
|
|
518
|
+
class R {
|
|
519
|
+
/**
|
|
520
|
+
* Constructor.
|
|
521
|
+
*
|
|
522
|
+
* @param {Logger} logger The logger.
|
|
523
|
+
* @param {LogLevel} logLevel The log level.
|
|
524
|
+
*/
|
|
525
|
+
constructor(s, e = o.Information) {
|
|
526
|
+
i(this, "_logger");
|
|
527
|
+
i(this, "_logLevel");
|
|
528
|
+
this._logger = s, this._logLevel = e;
|
|
529
|
+
}
|
|
530
|
+
/** @inheritdoc */
|
|
531
|
+
onPublish(s) {
|
|
532
|
+
this._logger.log(this._logLevel, `Publishing message to topic: ${s.topic}`, void 0, {
|
|
533
|
+
topic: s.topic ?? null,
|
|
534
|
+
message: s.message ?? null
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function x(r = 1, s) {
|
|
539
|
+
return new Promise((e, t) => {
|
|
540
|
+
setTimeout(() => {
|
|
541
|
+
s ? t(s) : e();
|
|
542
|
+
}, r);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
461
545
|
export {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
546
|
+
f as BroadcastChannelPlugin,
|
|
547
|
+
v as ConsoleReporter,
|
|
548
|
+
b as DynamicValuesEnricher,
|
|
549
|
+
P as InMemoryReporter,
|
|
465
550
|
o as LogLevel,
|
|
466
551
|
c as LogMessage,
|
|
467
552
|
T as Logger,
|
|
468
553
|
M as LoggerOptions,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
554
|
+
R as LoggerPlugin,
|
|
555
|
+
E as MultipleReporter,
|
|
556
|
+
m as PubSubHub,
|
|
557
|
+
d as ValuesEnricher,
|
|
558
|
+
y as XhrReporter,
|
|
559
|
+
w as XhrReporterOptions,
|
|
560
|
+
x as delay
|
|
475
561
|
};
|