standard-log 13.0.0 → 13.0.2

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 (132) hide show
  1. package/cjs/_virtual/_rolldown/runtime.js +23 -0
  2. package/cjs/console.d.ts +10 -7
  3. package/cjs/console.d.ts.map +1 -1
  4. package/cjs/console.js +54 -69
  5. package/cjs/console.js.map +1 -1
  6. package/cjs/errors.d.ts +9 -6
  7. package/cjs/errors.d.ts.map +1 -1
  8. package/cjs/errors.js +22 -45
  9. package/cjs/errors.js.map +1 -1
  10. package/cjs/formatter.d.ts +9 -6
  11. package/cjs/formatter.d.ts.map +1 -1
  12. package/cjs/formatter.js +42 -49
  13. package/cjs/formatter.js.map +1 -1
  14. package/cjs/index.d.ts +8 -9
  15. package/cjs/index.js +26 -28
  16. package/cjs/log_levels.d.ts +76 -73
  17. package/cjs/log_levels.d.ts.map +1 -1
  18. package/cjs/log_levels.js +104 -110
  19. package/cjs/log_levels.js.map +1 -1
  20. package/cjs/log_store.d.ts +20 -17
  21. package/cjs/log_store.d.ts.map +1 -1
  22. package/cjs/log_store.js +44 -39
  23. package/cjs/log_store.js.map +1 -1
  24. package/cjs/logger.d.ts +6 -3
  25. package/cjs/logger.d.ts.map +1 -1
  26. package/cjs/logger.js +66 -87
  27. package/cjs/logger.js.map +1 -1
  28. package/cjs/memory.d.ts +20 -17
  29. package/cjs/memory.d.ts.map +1 -1
  30. package/cjs/memory.js +55 -62
  31. package/cjs/memory.js.map +1 -1
  32. package/cjs/platform.browser.d.ts +7 -4
  33. package/cjs/platform.browser.d.ts.map +1 -1
  34. package/cjs/platform.browser.js +8 -6
  35. package/cjs/platform.browser.js.map +1 -1
  36. package/cjs/platform.d.ts +7 -4
  37. package/cjs/platform.d.ts.map +1 -1
  38. package/cjs/platform.js +9 -7
  39. package/cjs/platform.js.map +1 -1
  40. package/cjs/standard_log.ctx.d.ts +11 -8
  41. package/cjs/standard_log.ctx.d.ts.map +1 -1
  42. package/cjs/standard_log.ctx.js +6 -5
  43. package/cjs/standard_log.ctx.js.map +1 -1
  44. package/cjs/standard_log.d.ts +14 -12
  45. package/cjs/standard_log.d.ts.map +1 -1
  46. package/cjs/standard_log.js +84 -112
  47. package/cjs/standard_log.js.map +1 -1
  48. package/cjs/standard_log.testing.d.ts +16 -13
  49. package/cjs/standard_log.testing.d.ts.map +1 -1
  50. package/cjs/standard_log.testing.js +20 -35
  51. package/cjs/standard_log.testing.js.map +1 -1
  52. package/cjs/testing/index.d.ts +3 -3
  53. package/cjs/testing/index.js +3 -6
  54. package/cjs/types.d.ts +125 -124
  55. package/cjs/types.d.ts.map +1 -1
  56. package/cjs/types.js +0 -3
  57. package/dist/standard-log.esm.js +874 -1401
  58. package/dist/standard-log.esm.js.map +1 -1
  59. package/dist/standard-log.iife.js +952 -0
  60. package/dist/standard-log.iife.js.map +1 -0
  61. package/esm/console.d.ts +10 -7
  62. package/esm/console.d.ts.map +1 -1
  63. package/esm/console.js +54 -62
  64. package/esm/console.js.map +1 -1
  65. package/esm/errors.d.ts +9 -6
  66. package/esm/errors.d.ts.map +1 -1
  67. package/esm/errors.js +21 -21
  68. package/esm/errors.js.map +1 -1
  69. package/esm/formatter.d.ts +9 -6
  70. package/esm/formatter.d.ts.map +1 -1
  71. package/esm/formatter.js +38 -31
  72. package/esm/formatter.js.map +1 -1
  73. package/esm/index.d.ts +8 -9
  74. package/esm/index.js +7 -7
  75. package/esm/log_levels.d.ts +76 -73
  76. package/esm/log_levels.d.ts.map +1 -1
  77. package/esm/log_levels.js +102 -107
  78. package/esm/log_levels.js.map +1 -1
  79. package/esm/log_store.d.ts +20 -17
  80. package/esm/log_store.d.ts.map +1 -1
  81. package/esm/log_store.js +44 -37
  82. package/esm/log_store.js.map +1 -1
  83. package/esm/logger.d.ts +6 -3
  84. package/esm/logger.d.ts.map +1 -1
  85. package/esm/logger.js +66 -65
  86. package/esm/logger.js.map +1 -1
  87. package/esm/memory.d.ts +20 -17
  88. package/esm/memory.d.ts.map +1 -1
  89. package/esm/memory.js +55 -60
  90. package/esm/memory.js.map +1 -1
  91. package/esm/platform.browser.d.ts +7 -4
  92. package/esm/platform.browser.d.ts.map +1 -1
  93. package/esm/platform.browser.js +7 -3
  94. package/esm/platform.browser.js.map +1 -1
  95. package/esm/platform.d.ts +7 -4
  96. package/esm/platform.d.ts.map +1 -1
  97. package/esm/platform.js +8 -4
  98. package/esm/platform.js.map +1 -1
  99. package/esm/standard_log.ctx.d.ts +11 -8
  100. package/esm/standard_log.ctx.d.ts.map +1 -1
  101. package/esm/standard_log.ctx.js +6 -2
  102. package/esm/standard_log.ctx.js.map +1 -1
  103. package/esm/standard_log.d.ts +14 -12
  104. package/esm/standard_log.d.ts.map +1 -1
  105. package/esm/standard_log.js +83 -98
  106. package/esm/standard_log.js.map +1 -1
  107. package/esm/standard_log.testing.d.ts +16 -13
  108. package/esm/standard_log.testing.d.ts.map +1 -1
  109. package/esm/standard_log.testing.js +19 -20
  110. package/esm/standard_log.testing.js.map +1 -1
  111. package/esm/testing/index.d.ts +3 -3
  112. package/esm/testing/index.js +2 -2
  113. package/esm/types.d.ts +125 -124
  114. package/esm/types.d.ts.map +1 -1
  115. package/esm/types.js +0 -1
  116. package/package.json +8 -42
  117. package/cjs/index.d.ts.map +0 -1
  118. package/cjs/index.js.map +0 -1
  119. package/cjs/testing/index.d.ts.map +0 -1
  120. package/cjs/testing/index.js.map +0 -1
  121. package/cjs/types.js.map +0 -1
  122. package/dist/standard-log.es5.js +0 -10628
  123. package/dist/standard-log.es5.js.gz +0 -0
  124. package/dist/standard-log.es5.js.map +0 -1
  125. package/dist/standard-log.es5.js.map.gz +0 -0
  126. package/dist/standard-log.esm.js.gz +0 -0
  127. package/dist/standard-log.esm.js.map.gz +0 -0
  128. package/esm/index.d.ts.map +0 -1
  129. package/esm/index.js.map +0 -1
  130. package/esm/testing/index.d.ts.map +0 -1
  131. package/esm/testing/index.js.map +0 -1
  132. package/esm/types.js.map +0 -1
@@ -1,1457 +1,930 @@
1
- var StandardLog;
2
- /******/ (function() { // webpackBootstrap
3
- /******/ var __webpack_modules__ = ({
4
-
5
- /***/ "../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"
6
- /*!******************************************************************!*\
7
- !*** ../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js ***!
8
- \******************************************************************/
9
- (module) {
10
-
11
- /**
12
- * Helpers.
13
- */
14
-
15
- var s = 1000;
16
- var m = s * 60;
17
- var h = m * 60;
18
- var d = h * 24;
19
- var w = d * 7;
20
- var y = d * 365.25;
21
-
22
- /**
23
- * Parse or format the given `val`.
24
- *
25
- * Options:
26
- *
27
- * - `long` verbose formatting [false]
28
- *
29
- * @param {String|Number} val
30
- * @param {Object} [options]
31
- * @throws {Error} throw an error if val is not a non-empty string or a number
32
- * @return {String|Number}
33
- * @api public
34
- */
35
-
36
- module.exports = function (val, options) {
37
- options = options || {};
38
- var type = typeof val;
39
- if (type === 'string' && val.length > 0) {
40
- return parse(val);
41
- } else if (type === 'number' && isFinite(val)) {
42
- return options.long ? fmtLong(val) : fmtShort(val);
43
- }
44
- throw new Error(
45
- 'val is not a non-empty string or a valid number. val=' +
46
- JSON.stringify(val)
47
- );
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
48
18
  };
49
-
50
- /**
51
- * Parse the given `str` and return milliseconds.
52
- *
53
- * @param {String} str
54
- * @return {Number}
55
- * @api private
56
- */
57
-
58
- function parse(str) {
59
- str = String(str);
60
- if (str.length > 100) {
61
- return;
62
- }
63
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
64
- str
65
- );
66
- if (!match) {
67
- return;
68
- }
69
- var n = parseFloat(match[1]);
70
- var type = (match[2] || 'ms').toLowerCase();
71
- switch (type) {
72
- case 'years':
73
- case 'year':
74
- case 'yrs':
75
- case 'yr':
76
- case 'y':
77
- return n * y;
78
- case 'weeks':
79
- case 'week':
80
- case 'w':
81
- return n * w;
82
- case 'days':
83
- case 'day':
84
- case 'd':
85
- return n * d;
86
- case 'hours':
87
- case 'hour':
88
- case 'hrs':
89
- case 'hr':
90
- case 'h':
91
- return n * h;
92
- case 'minutes':
93
- case 'minute':
94
- case 'mins':
95
- case 'min':
96
- case 'm':
97
- return n * m;
98
- case 'seconds':
99
- case 'second':
100
- case 'secs':
101
- case 'sec':
102
- case 's':
103
- return n * s;
104
- case 'milliseconds':
105
- case 'millisecond':
106
- case 'msecs':
107
- case 'msec':
108
- case 'ms':
109
- return n;
110
- default:
111
- return undefined;
112
- }
113
- }
114
-
115
- /**
116
- * Short format for `ms`.
117
- *
118
- * @param {Number} ms
119
- * @return {String}
120
- * @api private
121
- */
122
-
123
- function fmtShort(ms) {
124
- var msAbs = Math.abs(ms);
125
- if (msAbs >= d) {
126
- return Math.round(ms / d) + 'd';
127
- }
128
- if (msAbs >= h) {
129
- return Math.round(ms / h) + 'h';
130
- }
131
- if (msAbs >= m) {
132
- return Math.round(ms / m) + 'm';
133
- }
134
- if (msAbs >= s) {
135
- return Math.round(ms / s) + 's';
136
- }
137
- return ms + 'ms';
138
- }
139
-
140
- /**
141
- * Long format for `ms`.
142
- *
143
- * @param {Number} ms
144
- * @return {String}
145
- * @api private
146
- */
147
-
148
- function fmtLong(ms) {
149
- var msAbs = Math.abs(ms);
150
- if (msAbs >= d) {
151
- return plural(ms, msAbs, d, 'day');
152
- }
153
- if (msAbs >= h) {
154
- return plural(ms, msAbs, h, 'hour');
155
- }
156
- if (msAbs >= m) {
157
- return plural(ms, msAbs, m, 'minute');
158
- }
159
- if (msAbs >= s) {
160
- return plural(ms, msAbs, s, 'second');
161
- }
162
- return ms + ' ms';
163
- }
164
-
165
- /**
166
- * Pluralization helper.
167
- */
168
-
169
- function plural(ms, msAbs, n, name) {
170
- var isPlural = msAbs >= n * 1.5;
171
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
172
- }
173
-
174
-
175
- /***/ },
176
-
177
- /***/ "./ts/console.ts"
178
- /*!***********************!*\
179
- !*** ./ts/console.ts ***!
180
- \***********************/
181
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
182
-
183
- "use strict";
184
- __webpack_require__.r(__webpack_exports__);
185
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
186
- /* harmony export */ createConsoleLogReporter: function() { return /* binding */ createConsoleLogReporter; },
187
- /* harmony export */ toConsoleMethod: function() { return /* binding */ toConsoleMethod; }
188
- /* harmony export */ });
189
- /* harmony import */ var type_plus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/unpartial@1.0.5/node_modules/unpartial/esm/index.js");
190
- /* harmony import */ var _formatter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./formatter.js */ "./ts/formatter.ts");
191
- /* harmony import */ var _log_levels_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./log_levels.js */ "./ts/log_levels.ts");
192
- /* harmony import */ var _platform_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./platform.js */ "./ts/platform.browser.ts");
193
-
194
-
195
-
196
-
197
- function toConsoleMethod(level) {
198
- switch (true) {
199
- // edge case in case none is somehow written
200
- case level <= 0:
201
- return 'debug';
202
- case level <= _log_levels_js__WEBPACK_IMPORTED_MODULE_2__.logLevels.error:
203
- return 'error';
204
- case level <= _log_levels_js__WEBPACK_IMPORTED_MODULE_2__.logLevels.warn:
205
- return 'warn';
206
- case level <= _log_levels_js__WEBPACK_IMPORTED_MODULE_2__.logLevels.info:
207
- return 'info';
208
- default:
209
- return 'debug';
210
- }
211
- }
212
- // istanbul ignore next
213
- /* eslint-disable no-console */
214
- function buildPolyfillConsole() {
215
- // old phantomjs does not have bind function
216
- const hasBind = !!console.log.bind;
217
- if (hasBind) {
218
- return {
219
- // the `typeof` guards against IE where `console.log.apply()`
220
- // results in error `Object doesn't support property or method 'apply'`
221
- debug: (typeof console.info === 'function' ? console.debug : console.log).bind(console),
222
- info: (typeof console.info === 'function' ? console.info : console.log).bind(console),
223
- warn: (typeof console.warn === 'function' ? console.warn : console.log).bind(console),
224
- error: (typeof console.error === 'function' ? console.error : console.log).bind(console)
225
- };
226
- }
227
- return {
228
- debug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),
229
- info: buildFn(typeof console.info === 'function' ? 'info' : 'log'),
230
- warn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),
231
- error: buildFn(typeof console.error === 'function' ? 'error' : 'log')
232
- };
233
- }
234
- // istanbul ignore next
235
- function buildFn(name) {
236
- return (...args) => {
237
- console[name](...args);
238
- };
239
- }
240
- function createConsoleLogReporter(options) {
241
- const { id, formatter, filter } = (0,type_plus__WEBPACK_IMPORTED_MODULE_0__.unpartial)({ id: 'console', formatter: _formatter_js__WEBPACK_IMPORTED_MODULE_1__.consoleFormatter }, options);
242
- if (!_platform_js__WEBPACK_IMPORTED_MODULE_3__.polyfill.console)
243
- _platform_js__WEBPACK_IMPORTED_MODULE_3__.polyfill.console = buildPolyfillConsole();
244
- return Object.freeze({
245
- id,
246
- isConsoleReporter: true,
247
- get formatter() {
248
- return formatter;
249
- },
250
- get filter() {
251
- return filter;
252
- },
253
- console: _platform_js__WEBPACK_IMPORTED_MODULE_3__.polyfill.console,
254
- write(entry) {
255
- if (filter && !filter(entry))
256
- return;
257
- const values = formatter(entry);
258
- const method = toConsoleMethod(entry.level);
259
- this.console[method](...values);
260
- }
261
- });
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ //#region ../../node_modules/.pnpm/unpartial@1.0.5/node_modules/unpartial/esm/index.js
25
+ function required(source1, source2, source3) {
26
+ return merge([
27
+ source1,
28
+ source2,
29
+ source3
30
+ ], (p, e) => {
31
+ return {
32
+ ...p,
33
+ ...e
34
+ };
35
+ });
262
36
  }
263
-
264
-
265
- /***/ },
266
-
267
- /***/ "./ts/errors.ts"
268
- /*!**********************!*\
269
- !*** ./ts/errors.ts ***!
270
- \**********************/
271
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
272
-
273
- "use strict";
274
- __webpack_require__.r(__webpack_exports__);
275
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
276
- /* harmony export */ InvalidId: function() { return /* binding */ InvalidId; },
277
- /* harmony export */ StandardLogError: function() { return /* binding */ StandardLogError; }
278
- /* harmony export */ });
279
- /* harmony import */ var iso_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! iso-error */ "../../node_modules/.pnpm/iso-error@6.0.3/node_modules/iso-error/esm/index.js");
280
-
281
- /**
282
- * @deprecated No longer used since 11.2.0
283
- */
284
- class StandardLogError extends iso_error__WEBPACK_IMPORTED_MODULE_0__.ModuleError {
285
- constructor(description, options) {
286
- super('standard-log', description, options);
287
- }
37
+ function merge(entries, reducer) {
38
+ if (entries[0] === void 0 || entries[0] === null) return entries[0];
39
+ return entries.filter((x) => !!x).reduce(reducer, {});
288
40
  }
289
- /**
290
- * @deprecated no longer used since 11.2.0
291
- */
292
- class InvalidId extends StandardLogError {
293
- constructor(id, options) {
294
- super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options);
295
- Object.defineProperty(this, "id", {
296
- enumerable: true,
297
- configurable: true,
298
- writable: true,
299
- value: id
300
- });
301
- }
41
+ function unpartial(s1, s2, s3) {
42
+ if (s1 === void 0 || s1 === null) return s1;
43
+ return [
44
+ s1,
45
+ s2,
46
+ s3
47
+ ].filter(notNil).reduce((p, s) => ({
48
+ ...p,
49
+ ...trimNilProps(s)
50
+ }), {});
302
51
  }
303
-
304
-
305
- /***/ },
306
-
307
- /***/ "./ts/formatter.ts"
308
- /*!*************************!*\
309
- !*** ./ts/formatter.ts ***!
310
- \*************************/
311
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
312
-
313
- "use strict";
314
- __webpack_require__.r(__webpack_exports__);
315
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
316
- /* harmony export */ consoleFormatter: function() { return /* binding */ consoleFormatter; },
317
- /* harmony export */ createTimestampFormatter: function() { return /* binding */ createTimestampFormatter; },
318
- /* harmony export */ formatLogLevel: function() { return /* binding */ formatLogLevel; },
319
- /* harmony export */ plainLogFormatter: function() { return /* binding */ plainLogFormatter; }
320
- /* harmony export */ });
321
- /* harmony import */ var ms__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ms */ "../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js");
322
- /* harmony import */ var ms__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ms__WEBPACK_IMPORTED_MODULE_0__);
323
- /* harmony import */ var _log_levels_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./log_levels.js */ "./ts/log_levels.ts");
324
-
325
-
326
- function createTimestampFormatter(format) {
327
- switch (format) {
328
- case 'none':
329
- return (_timestamp) => undefined;
330
- case 'iso':
331
- return (timestamp) => timestamp.toISOString();
332
- case 'elapsed': {
333
- let lastTick;
334
- return (timestamp) => {
335
- const newTick = timestamp.getTime();
336
- const result = ms__WEBPACK_IMPORTED_MODULE_0___default()(lastTick === undefined ? 0 : newTick - lastTick);
337
- lastTick = newTick;
338
- return result;
339
- };
340
- }
341
- }
52
+ function trimNilProps(value) {
53
+ return Object.keys(value).reduce((p, k) => {
54
+ if (notNil(value[k])) p[k] = value[k];
55
+ return p;
56
+ }, {});
342
57
  }
343
- function formatLogLevel(level) {
344
- return `(${(0,_log_levels_js__WEBPACK_IMPORTED_MODULE_1__.toLogLevelName)(level).toUpperCase()})`;
58
+ function notNil(value) {
59
+ return value !== null && value !== void 0;
345
60
  }
346
- /**
347
- * Formats log entry as plain text with the following format:
348
- * `timestamp id level ...args`
349
- *
350
- * This is typically useful for writing logs to file
351
- */
352
- function plainLogFormatter({ id, level, args, timestamp }) {
353
- return [timestamp.toISOString(), id, formatLogLevel(level), ...args];
61
+ //#endregion
62
+ //#region ../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/mapKey.js
63
+ function mapKey(subject, predicate, thisArg) {
64
+ return Object.keys(subject).map(function(k, i, a) {
65
+ return predicate.apply(this, [
66
+ k,
67
+ i,
68
+ a,
69
+ subject
70
+ ]);
71
+ }, thisArg);
72
+ }
73
+ //#endregion
74
+ //#region ../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/reduceKey.js
75
+ function reduceByKey(subject, callbackfn, initialValue) {
76
+ return Object.keys(subject).reduce((p, k, i, a) => callbackfn(p, k, i, a, subject), initialValue);
354
77
  }
355
78
  /**
356
- * Formats log entry like default console log.
357
- */
358
- function consoleFormatter({ args }) {
359
- return args;
360
- }
361
-
362
-
363
- /***/ },
364
-
365
- /***/ "./ts/log_levels.ts"
366
- /*!**************************!*\
367
- !*** ./ts/log_levels.ts ***!
368
- \**************************/
369
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
370
-
371
- "use strict";
372
- __webpack_require__.r(__webpack_exports__);
373
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
374
- /* harmony export */ DEFAULT_LOG_METHOD_NAMES: function() { return /* binding */ DEFAULT_LOG_METHOD_NAMES; },
375
- /* harmony export */ logLevels: function() { return /* binding */ logLevels; },
376
- /* harmony export */ toLogLevel: function() { return /* binding */ toLogLevel; },
377
- /* harmony export */ toLogLevelName: function() { return /* binding */ toLogLevelName; }
378
- /* harmony export */ });
79
+ * @deprecated renamed to reduceByKey
80
+ */
81
+ const reduceKey = reduceByKey;
82
+ //#endregion
83
+ //#region ../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/record.js
84
+ function record(value) {
85
+ const r = Object.create(null);
86
+ return value ? Object.assign(r, value) : r;
87
+ }
88
+ //#endregion
89
+ //#region ts/log_levels.ts
90
+ var import_ms = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
91
+ /**
92
+ * Helpers.
93
+ */
94
+ var s = 1e3;
95
+ var m = s * 60;
96
+ var h = m * 60;
97
+ var d = h * 24;
98
+ var w = d * 7;
99
+ var y = d * 365.25;
100
+ /**
101
+ * Parse or format the given `val`.
102
+ *
103
+ * Options:
104
+ *
105
+ * - `long` verbose formatting [false]
106
+ *
107
+ * @param {String|Number} val
108
+ * @param {Object} [options]
109
+ * @throws {Error} throw an error if val is not a non-empty string or a number
110
+ * @return {String|Number}
111
+ * @api public
112
+ */
113
+ module.exports = function(val, options) {
114
+ options = options || {};
115
+ var type = typeof val;
116
+ if (type === "string" && val.length > 0) return parse(val);
117
+ else if (type === "number" && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
118
+ throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
119
+ };
120
+ /**
121
+ * Parse the given `str` and return milliseconds.
122
+ *
123
+ * @param {String} str
124
+ * @return {Number}
125
+ * @api private
126
+ */
127
+ function parse(str) {
128
+ str = String(str);
129
+ if (str.length > 100) return;
130
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
131
+ if (!match) return;
132
+ var n = parseFloat(match[1]);
133
+ switch ((match[2] || "ms").toLowerCase()) {
134
+ case "years":
135
+ case "year":
136
+ case "yrs":
137
+ case "yr":
138
+ case "y": return n * y;
139
+ case "weeks":
140
+ case "week":
141
+ case "w": return n * w;
142
+ case "days":
143
+ case "day":
144
+ case "d": return n * d;
145
+ case "hours":
146
+ case "hour":
147
+ case "hrs":
148
+ case "hr":
149
+ case "h": return n * h;
150
+ case "minutes":
151
+ case "minute":
152
+ case "mins":
153
+ case "min":
154
+ case "m": return n * m;
155
+ case "seconds":
156
+ case "second":
157
+ case "secs":
158
+ case "sec":
159
+ case "s": return n * s;
160
+ case "milliseconds":
161
+ case "millisecond":
162
+ case "msecs":
163
+ case "msec":
164
+ case "ms": return n;
165
+ default: return;
166
+ }
167
+ }
168
+ /**
169
+ * Short format for `ms`.
170
+ *
171
+ * @param {Number} ms
172
+ * @return {String}
173
+ * @api private
174
+ */
175
+ function fmtShort(ms) {
176
+ var msAbs = Math.abs(ms);
177
+ if (msAbs >= d) return Math.round(ms / d) + "d";
178
+ if (msAbs >= h) return Math.round(ms / h) + "h";
179
+ if (msAbs >= m) return Math.round(ms / m) + "m";
180
+ if (msAbs >= s) return Math.round(ms / s) + "s";
181
+ return ms + "ms";
182
+ }
183
+ /**
184
+ * Long format for `ms`.
185
+ *
186
+ * @param {Number} ms
187
+ * @return {String}
188
+ * @api private
189
+ */
190
+ function fmtLong(ms) {
191
+ var msAbs = Math.abs(ms);
192
+ if (msAbs >= d) return plural(ms, msAbs, d, "day");
193
+ if (msAbs >= h) return plural(ms, msAbs, h, "hour");
194
+ if (msAbs >= m) return plural(ms, msAbs, m, "minute");
195
+ if (msAbs >= s) return plural(ms, msAbs, s, "second");
196
+ return ms + " ms";
197
+ }
198
+ /**
199
+ * Pluralization helper.
200
+ */
201
+ function plural(ms, msAbs, n, name) {
202
+ var isPlural = msAbs >= n * 1.5;
203
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
204
+ }
205
+ })))(), 1);
379
206
  const logLevels = {
380
- /**
381
- * none: 0
382
- */
383
- none: 0,
384
- /**
385
- * emergency: 100
386
- *
387
- * emergency -> alert
388
- */
389
- emergency: 100,
390
- /**
391
- * alert: 200
392
- *
393
- * emergency -> alert -> critical
394
- */
395
- alert: 200,
396
- /**
397
- * critical: 300
398
- *
399
- * alert -> critical -> error
400
- */
401
- critical: 300,
402
- /**
403
- * error: 400
404
- *
405
- * critical -> error -> warn
406
- */
407
- error: 400,
408
- /**
409
- * warn: 500
410
- *
411
- * error -> warn -> notice
412
- */
413
- warn: 500,
414
- /**
415
- * notice: 600
416
- *
417
- * warn -> notice -> info
418
- */
419
- notice: 600,
420
- /**
421
- * info: 700
422
- *
423
- * notice -> info -> debug
424
- */
425
- info: 700,
426
- /**
427
- * debug: 800
428
- *
429
- * info -> debug -> trace
430
- */
431
- debug: 800,
432
- /**
433
- * trace: 900
434
- *
435
- * debug -> trace -> planck
436
- */
437
- trace: 900,
438
- /**
439
- * planck: Infinity
440
- * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
441
- *
442
- * trace -> planck
443
- */
444
- planck: Number.POSITIVE_INFINITY,
445
- /**
446
- * all: Infinity
447
- */
448
- all: Number.POSITIVE_INFINITY
207
+ /**
208
+ * none: 0
209
+ */
210
+ none: 0,
211
+ /**
212
+ * emergency: 100
213
+ *
214
+ * emergency -> alert
215
+ */
216
+ emergency: 100,
217
+ /**
218
+ * alert: 200
219
+ *
220
+ * emergency -> alert -> critical
221
+ */
222
+ alert: 200,
223
+ /**
224
+ * critical: 300
225
+ *
226
+ * alert -> critical -> error
227
+ */
228
+ critical: 300,
229
+ /**
230
+ * error: 400
231
+ *
232
+ * critical -> error -> warn
233
+ */
234
+ error: 400,
235
+ /**
236
+ * warn: 500
237
+ *
238
+ * error -> warn -> notice
239
+ */
240
+ warn: 500,
241
+ /**
242
+ * notice: 600
243
+ *
244
+ * warn -> notice -> info
245
+ */
246
+ notice: 600,
247
+ /**
248
+ * info: 700
249
+ *
250
+ * notice -> info -> debug
251
+ */
252
+ info: 700,
253
+ /**
254
+ * debug: 800
255
+ *
256
+ * info -> debug -> trace
257
+ */
258
+ debug: 800,
259
+ /**
260
+ * trace: 900
261
+ *
262
+ * debug -> trace -> planck
263
+ */
264
+ trace: 900,
265
+ /**
266
+ * planck: Infinity
267
+ * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.
268
+ *
269
+ * trace -> planck
270
+ */
271
+ planck: Number.POSITIVE_INFINITY,
272
+ /**
273
+ * all: Infinity
274
+ */
275
+ all: Number.POSITIVE_INFINITY
449
276
  };
450
277
  /**
451
- * Convert default log level value to log level name.
452
- */
278
+ * Convert default log level value to log level name.
279
+ */
453
280
  function toLogLevelName(level) {
454
- if (level <= 100)
455
- return 'emergency';
456
- if (level <= 200)
457
- return 'alert';
458
- if (level <= 300)
459
- return 'critical';
460
- if (level <= 400)
461
- return 'error';
462
- if (level <= 500)
463
- return 'warn';
464
- if (level <= 600)
465
- return 'notice';
466
- if (level <= 700)
467
- return 'info';
468
- if (level <= 800)
469
- return 'debug';
470
- if (level <= 900)
471
- return 'trace';
472
- return 'planck';
281
+ if (level <= 100) return "emergency";
282
+ if (level <= 200) return "alert";
283
+ if (level <= 300) return "critical";
284
+ if (level <= 400) return "error";
285
+ if (level <= 500) return "warn";
286
+ if (level <= 600) return "notice";
287
+ if (level <= 700) return "info";
288
+ if (level <= 800) return "debug";
289
+ if (level <= 900) return "trace";
290
+ return "planck";
473
291
  }
474
292
  /**
475
- * Convert default log level name to log level value.
476
- */
293
+ * Convert default log level name to log level value.
294
+ */
477
295
  function toLogLevel(name) {
478
- return logLevels[name.toLocaleLowerCase()];
296
+ return logLevels[name.toLocaleLowerCase()];
479
297
  }
480
298
  const DEFAULT_LOG_METHOD_NAMES = [
481
- 'emergency',
482
- 'alert',
483
- 'critical',
484
- 'error',
485
- 'warn',
486
- 'notice',
487
- 'info',
488
- 'debug',
489
- 'trace',
490
- 'planck'
299
+ "emergency",
300
+ "alert",
301
+ "critical",
302
+ "error",
303
+ "warn",
304
+ "notice",
305
+ "info",
306
+ "debug",
307
+ "trace",
308
+ "planck"
491
309
  ];
492
-
493
-
494
- /***/ },
495
-
496
- /***/ "./ts/log_store.ts"
497
- /*!*************************!*\
498
- !*** ./ts/log_store.ts ***!
499
- \*************************/
500
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
501
-
502
- "use strict";
503
- __webpack_require__.r(__webpack_exports__);
504
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
505
- /* harmony export */ createLogStore: function() { return /* binding */ createLogStore; },
506
- /* harmony export */ logLevelStore: function() { return /* binding */ logLevelStore; }
507
- /* harmony export */ });
508
- /* harmony import */ var type_plus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/mapKey.js");
509
- /* harmony import */ var type_plus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/record.js");
510
- /* harmony import */ var type_plus__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/reduceKey.js");
511
- /* harmony import */ var _console_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./console.js */ "./ts/console.ts");
512
- /* harmony import */ var _log_levels_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./log_levels.js */ "./ts/log_levels.ts");
513
-
514
-
515
-
516
- function createLogStore(options) {
517
- return {
518
- loggers: (0,type_plus__WEBPACK_IMPORTED_MODULE_1__.record)(),
519
- nonConsoleLoggers: (0,type_plus__WEBPACK_IMPORTED_MODULE_1__.record)(),
520
- reporters: options.reporters || [(0,_console_js__WEBPACK_IMPORTED_MODULE_3__.createConsoleLogReporter)()],
521
- logLevel: options.logLevel,
522
- logLevelStore: logLevelStore(options)
523
- };
524
- }
525
- function logLevelStore(options) {
526
- const customLevels = options.customLevels || (0,type_plus__WEBPACK_IMPORTED_MODULE_1__.record)();
527
- const store = {
528
- customLevels,
529
- customLevelsReverse: (0,type_plus__WEBPACK_IMPORTED_MODULE_2__.reduceByKey)(customLevels, (p, k) => {
530
- p[customLevels[k]] = k;
531
- return p;
532
- }, {})
533
- };
534
- return {
535
- getName(level) {
536
- var _a;
537
- return (_a = store.customLevelsReverse[level]) !== null && _a !== void 0 ? _a : (0,_log_levels_js__WEBPACK_IMPORTED_MODULE_4__.toLogLevelName)(level);
538
- },
539
- getLevel(name) {
540
- var _a;
541
- return (_a = store.customLevels[name]) !== null && _a !== void 0 ? _a : (0,_log_levels_js__WEBPACK_IMPORTED_MODULE_4__.toLogLevel)(name);
542
- },
543
- getAllLevels() {
544
- return (0,type_plus__WEBPACK_IMPORTED_MODULE_2__.reduceKey)(_log_levels_js__WEBPACK_IMPORTED_MODULE_4__.logLevels, (result, name) => {
545
- if (name !== 'none' && name !== 'all')
546
- result.push({ name, level: _log_levels_js__WEBPACK_IMPORTED_MODULE_4__.logLevels[name] });
547
- return result;
548
- }, (0,type_plus__WEBPACK_IMPORTED_MODULE_0__.mapKey)(store.customLevels, name => ({ name, level: store.customLevels[name] })));
549
- }
550
- };
551
- }
552
-
553
-
554
- /***/ },
555
-
556
- /***/ "./ts/logger.ts"
557
- /*!**********************!*\
558
- !*** ./ts/logger.ts ***!
559
- \**********************/
560
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
561
-
562
- "use strict";
563
- __webpack_require__.r(__webpack_exports__);
564
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
565
- /* harmony export */ createLogger: function() { return /* binding */ createLogger; }
566
- /* harmony export */ });
567
- /* harmony import */ var _log_levels_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./log_levels.js */ "./ts/log_levels.ts");
568
-
569
- function createLogger(store, id, options) {
570
- var _a;
571
- id = sanitizeId(id);
572
- const writeTo = (_a = options === null || options === void 0 ? void 0 : options.writeTo) !== null && _a !== void 0 ? _a : (() => true);
573
- const [filter, reporters] = typeof writeTo === 'string'
574
- ? [id => id === writeTo, store.reporters]
575
- : writeTo instanceof RegExp
576
- ? [id => writeTo.test(id), store.reporters]
577
- : typeof writeTo === 'function'
578
- ? [writeTo, store.reporters]
579
- : [() => true, [writeTo]];
580
- function write(entry) {
581
- writeToReporters(reporters, entry, filter);
582
- }
583
- const logger = {
584
- level: options === null || options === void 0 ? void 0 : options.level,
585
- write
586
- };
587
- Object.defineProperties(logger, {
588
- id: { value: id, writable: false },
589
- count: {
590
- writable: false,
591
- value: (counter => (...args) => {
592
- if (shouldLog(store, _log_levels_js__WEBPACK_IMPORTED_MODULE_0__.logLevels.debug, logger.level))
593
- write({
594
- id,
595
- level: _log_levels_js__WEBPACK_IMPORTED_MODULE_0__.logLevels.debug,
596
- args: [++counter, ...args],
597
- timestamp: new Date()
598
- });
599
- })(0)
600
- },
601
- on: {
602
- writable: false,
603
- value: (level, logFn) => {
604
- var _a;
605
- const logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level) : level;
606
- if (shouldLog(store, logLevel, logger.level)) {
607
- const methodName = store.logLevelStore.getName(logLevel);
608
- const bindedMethod = logger[methodName].bind(logger);
609
- const result = logFn(bindedMethod, (_a = logger.level) !== null && _a !== void 0 ? _a : store.logLevel);
610
- if (result)
611
- bindedMethod(result);
612
- }
613
- }
614
- }
615
- });
616
- store.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {
617
- Object.defineProperty(logger, name, {
618
- writable: false,
619
- value: (...args) => {
620
- if (shouldLog(store, level, logger.level))
621
- write({ id, level, args, timestamp: new Date() });
622
- }
623
- });
624
- });
625
- return logger;
626
- }
627
- function sanitizeId(id) {
628
- return id.replace(/[`~!#$%^&*()=+[\]{},|<>?]/g, '-');
310
+ //#endregion
311
+ //#region ts/formatter.ts
312
+ function createTimestampFormatter(format) {
313
+ switch (format) {
314
+ case "none": return (_timestamp) => void 0;
315
+ case "iso": return (timestamp) => timestamp.toISOString();
316
+ case "elapsed": {
317
+ let lastTick;
318
+ return (timestamp) => {
319
+ const newTick = timestamp.getTime();
320
+ const result = (0, import_ms.default)(lastTick === void 0 ? 0 : newTick - lastTick);
321
+ lastTick = newTick;
322
+ return result;
323
+ };
324
+ }
325
+ }
629
326
  }
630
- function writeToReporters(reporters, logEntry, filter) {
631
- reporters.filter(r => filter(r.id)).forEach(r => r.write(logEntry));
327
+ function formatLogLevel(level) {
328
+ return `(${toLogLevelName(level).toUpperCase()})`;
632
329
  }
633
330
  /**
634
- * Determines should you log.
635
- * @param loggerLevel Log level of the logger.
636
- * It can be undefined which the global log level will be used.
637
- */
638
- function shouldLog(store, targetLevel, loggerLevel) {
639
- return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel);
640
- }
641
-
642
-
643
- /***/ },
644
-
645
- /***/ "./ts/memory.ts"
646
- /*!**********************!*\
647
- !*** ./ts/memory.ts ***!
648
- \**********************/
649
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
650
-
651
- "use strict";
652
- __webpack_require__.r(__webpack_exports__);
653
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
654
- /* harmony export */ createMemoryLogReporter: function() { return /* binding */ createMemoryLogReporter; },
655
- /* harmony export */ createMemoryWithConsoleLogReporter: function() { return /* binding */ createMemoryWithConsoleLogReporter; },
656
- /* harmony export */ toMessageWithLevel: function() { return /* binding */ toMessageWithLevel; }
657
- /* harmony export */ });
658
- /* harmony import */ var type_plus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/unpartial@1.0.5/node_modules/unpartial/esm/index.js");
659
- /* harmony import */ var _console_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./console.js */ "./ts/console.ts");
660
- /* harmony import */ var _formatter_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./formatter.js */ "./ts/formatter.ts");
661
- /* harmony import */ var _platform_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./platform.js */ "./ts/platform.browser.ts");
662
-
663
-
664
-
665
-
666
- function toMessageWithLevel(logs) {
667
- return (logs
668
- .map(_platform_js__WEBPACK_IMPORTED_MODULE_3__.toInspectLogEntry)
669
- .map(log => `${(0,_formatter_js__WEBPACK_IMPORTED_MODULE_2__.formatLogLevel)(log.level)} ${log.args.join(' ')}`)
670
- .join('\n')
671
- // if it has more than this log,
672
- // we assume it is running under tests,
673
- // and remove this log to simplify testing.
674
- .replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, ''));
675
- }
676
- function createMemoryLogReporter(options) {
677
- return Object.freeze(buildMemoryReporter((0,type_plus__WEBPACK_IMPORTED_MODULE_0__.unpartial)({ id: 'memory' }, options)));
678
- }
679
- function buildMemoryReporter(options) {
680
- const { id, formatter, filter } = (0,type_plus__WEBPACK_IMPORTED_MODULE_0__.required)({ id: 'memory', formatter: (e) => e }, options);
681
- const logs = [];
682
- return {
683
- id,
684
- get formatter() {
685
- return formatter;
686
- },
687
- get filter() {
688
- return filter;
689
- },
690
- logs,
691
- write(entry) {
692
- if (filter && !filter(entry))
693
- return;
694
- logs.push(formatter(entry));
695
- },
696
- getLogMessage() {
697
- return this.getLogMessages().join('\n');
698
- },
699
- getLogMessages() {
700
- return logs.map(_platform_js__WEBPACK_IMPORTED_MODULE_3__.toInspectLogEntry).map(log => log.args.join(' '));
701
- },
702
- getLogMessagesWithLevel() {
703
- return logs.map(_platform_js__WEBPACK_IMPORTED_MODULE_3__.toInspectLogEntry).map(log => `${(0,_formatter_js__WEBPACK_IMPORTED_MODULE_2__.formatLogLevel)(log.level)} ${log.args.join(' ')}`);
704
- },
705
- getLogMessagesWithIdAndLevel() {
706
- return logs
707
- .map(_platform_js__WEBPACK_IMPORTED_MODULE_3__.toInspectLogEntry)
708
- .map(log => `${log.id} ${(0,_formatter_js__WEBPACK_IMPORTED_MODULE_2__.formatLogLevel)(log.level)} ${log.args.join(' ')}`);
709
- },
710
- getLogMessageWithLevel() {
711
- return toMessageWithLevel(logs);
712
- },
713
- /**
714
- * emit the saved log to console for easy debugging
715
- */
716
- emit() {
717
- const reporter = (0,_console_js__WEBPACK_IMPORTED_MODULE_1__.createConsoleLogReporter)();
718
- logs.forEach(l => reporter.write(l));
719
- }
720
- };
331
+ * Formats log entry as plain text with the following format:
332
+ * `timestamp id level ...args`
333
+ *
334
+ * This is typically useful for writing logs to file
335
+ */
336
+ function plainLogFormatter({ id, level, args, timestamp }) {
337
+ return [
338
+ timestamp.toISOString(),
339
+ id,
340
+ formatLogLevel(level),
341
+ ...args
342
+ ];
721
343
  }
722
- function createMemoryWithConsoleLogReporter(options) {
723
- return Object.freeze(Object.assign(buildMemoryReporter((0,type_plus__WEBPACK_IMPORTED_MODULE_0__.unpartial)({ id: 'memory-with-console' }, options)), {
724
- isConsoleReporter: true
725
- }));
344
+ /**
345
+ * Formats log entry like default console log.
346
+ */
347
+ function consoleFormatter({ args }) {
348
+ return args;
726
349
  }
727
-
728
-
729
- /***/ },
730
-
731
- /***/ "./ts/platform.browser.ts"
732
- /*!********************************!*\
733
- !*** ./ts/platform.browser.ts ***!
734
- \********************************/
735
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
736
-
737
- "use strict";
738
- __webpack_require__.r(__webpack_exports__);
739
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
740
- /* harmony export */ polyfill: function() { return /* binding */ polyfill; },
741
- /* harmony export */ toInspectLogEntry: function() { return /* binding */ toInspectLogEntry; }
742
- /* harmony export */ });
743
- /* harmony import */ var type_plus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/record.js");
744
-
350
+ //#endregion
351
+ //#region ts/platform.browser.ts
745
352
  const toInspectLogEntry = (e) => e;
746
- const polyfill = (0,type_plus__WEBPACK_IMPORTED_MODULE_0__.record)();
747
-
748
-
749
- /***/ },
750
-
751
- /***/ "./ts/standard_log.ctx.ts"
752
- /*!********************************!*\
753
- !*** ./ts/standard_log.ctx.ts ***!
754
- \********************************/
755
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
756
-
757
- "use strict";
758
- __webpack_require__.r(__webpack_exports__);
759
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
760
- /* harmony export */ ctx: function() { return /* binding */ ctx; }
761
- /* harmony export */ });
762
- /* harmony import */ var type_plus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/record.js");
763
-
764
- const ctx = (0,type_plus__WEBPACK_IMPORTED_MODULE_0__.record)();
765
-
766
-
767
- /***/ },
768
-
769
- /***/ "./ts/standard_log.ts"
770
- /*!****************************!*\
771
- !*** ./ts/standard_log.ts ***!
772
- \****************************/
773
- (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
774
-
775
- "use strict";
776
- __webpack_require__.r(__webpack_exports__);
777
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
778
- /* harmony export */ configGlobal: function() { return /* binding */ configGlobal; },
779
- /* harmony export */ createStandardLog: function() { return /* binding */ createStandardLog; },
780
- /* harmony export */ createStandardLogClosure: function() { return /* binding */ createStandardLogClosure; },
781
- /* harmony export */ getLogger: function() { return /* binding */ getLogger; },
782
- /* harmony export */ suppressLogs: function() { return /* binding */ suppressLogs; }
783
- /* harmony export */ });
784
- /* harmony import */ var type_plus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/unpartial@1.0.5/node_modules/unpartial/esm/index.js");
785
- /* harmony import */ var type_plus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/record.js");
786
- /* harmony import */ var _log_levels_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./log_levels.js */ "./ts/log_levels.ts");
787
- /* harmony import */ var _log_store_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./log_store.js */ "./ts/log_store.ts");
788
- /* harmony import */ var _logger_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger.js */ "./ts/logger.ts");
789
- /* harmony import */ var _standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./standard_log.ctx.js */ "./ts/standard_log.ctx.ts");
790
-
791
-
792
-
793
-
794
-
795
- function createStandardLog(options) {
796
- var _a;
797
- const closure = createStandardLogClosure(options);
798
- if ((_a = options === null || options === void 0 ? void 0 : options.reporters) === null || _a === void 0 ? void 0 : _a.some(r => !r.id)) {
799
- const log = closure.standardLog.getLogger('standard-log');
800
- log.critical(`Detected reporter with empty id. This is not allowed as it will create problems with feature like 'getNonConsoleLogger()'. Please add an id to your reporter.`);
801
- }
802
- if (!_standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl)
803
- _standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl = closure;
804
- return closure.standardLog;
805
- }
806
- function noop() { }
807
- function createStandardLogClosure(options) {
808
- var _a, _b, _c;
809
- // TODO reporter.id must not be empty
810
- const store = (0,_log_store_js__WEBPACK_IMPORTED_MODULE_3__.createLogStore)((0,type_plus__WEBPACK_IMPORTED_MODULE_0__.required)({ logLevel: _log_levels_js__WEBPACK_IMPORTED_MODULE_2__.logLevels.info }, options));
811
- const nonConsoleReporters = (_b = (_a = options === null || options === void 0 ? void 0 : options.reporters) === null || _a === void 0 ? void 0 : _a.filter(r => !r.isConsoleReporter).map(r => r.id)) !== null && _b !== void 0 ? _b : [];
812
- const logMethods = _log_levels_js__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_LOG_METHOD_NAMES.concat(Object.keys((_c = options === null || options === void 0 ? void 0 : options.customLevels) !== null && _c !== void 0 ? _c : {})).concat([
813
- 'on',
814
- 'count',
815
- 'write'
816
- ]);
817
- return {
818
- store,
819
- standardLog: {
820
- get logLevel() {
821
- return store.logLevel;
822
- },
823
- toLogLevelName(level) {
824
- return store.logLevelStore.getName(level);
825
- },
826
- toLogLevel(name) {
827
- return store.logLevelStore.getLevel(name);
828
- },
829
- getLogger(id, options) {
830
- if (store.loggers[id])
831
- return store.loggers[id];
832
- return (store.loggers[id] = (0,_logger_js__WEBPACK_IMPORTED_MODULE_4__.createLogger)(store, id, { ssf: this.getLogger, ...options }));
833
- },
834
- getNonConsoleLogger(id, options) {
835
- if (store.nonConsoleLoggers[id])
836
- return store.nonConsoleLoggers[id];
837
- if (store.loggers[id]) {
838
- const log = this.getLogger('standard-log');
839
- log.warn(`attempt to create a non-console logger with existing id ('${id}'), ignoring`);
840
- return (store.nonConsoleLoggers[id] = createDummyLogger(logMethods));
841
- }
842
- return (store.nonConsoleLoggers[id] =
843
- nonConsoleReporters.length === 0
844
- ? createDummyLogger(logMethods)
845
- : (0,_logger_js__WEBPACK_IMPORTED_MODULE_4__.createLogger)(store, id, {
846
- ssf: this.getNonConsoleLogger,
847
- ...options,
848
- writeTo(reporterId) {
849
- return nonConsoleReporters.indexOf(reporterId) >= 0;
850
- }
851
- }));
852
- }
853
- }
854
- };
855
- }
856
- function createDummyLogger(logMethods) {
857
- return logMethods.reduce((p, m) => {
858
- p[m] = noop;
859
- return p;
860
- }, (0,type_plus__WEBPACK_IMPORTED_MODULE_1__.record)());
861
- }
862
- function suppressLogs(block, ...logs) {
863
- const origLevels = logs.map(l => l.level);
864
- logs.forEach(l => (l.level = _log_levels_js__WEBPACK_IMPORTED_MODULE_2__.logLevels.none));
865
- const result = block();
866
- logs.forEach((l, i) => (l.level = origLevels[i]));
867
- return result;
868
- }
869
- function getLogger(id, options) {
870
- return getGlobalSL().getLogger(id, options);
353
+ const polyfill = record();
354
+ //#endregion
355
+ //#region ts/console.ts
356
+ function toConsoleMethod(level) {
357
+ switch (true) {
358
+ case level <= 0: return "debug";
359
+ case level <= logLevels.error: return "error";
360
+ case level <= logLevels.warn: return "warn";
361
+ case level <= logLevels.info: return "info";
362
+ default: return "debug";
363
+ }
871
364
  }
872
- function getGlobalSL() {
873
- if (!_standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl)
874
- _standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl = createStandardLogClosure();
875
- return _standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl.standardLog;
365
+ // istanbul ignore next
366
+ function buildPolyfillConsole() {
367
+ if (!!console.log.bind) return {
368
+ debug: (typeof console.info === "function" ? console.debug : console.log).bind(console),
369
+ info: (typeof console.info === "function" ? console.info : console.log).bind(console),
370
+ warn: (typeof console.warn === "function" ? console.warn : console.log).bind(console),
371
+ error: (typeof console.error === "function" ? console.error : console.log).bind(console)
372
+ };
373
+ return {
374
+ debug: buildFn(typeof console.debug === "function" ? "debug" : "log"),
375
+ info: buildFn(typeof console.info === "function" ? "info" : "log"),
376
+ warn: buildFn(typeof console.warn === "function" ? "warn" : "log"),
377
+ error: buildFn(typeof console.error === "function" ? "error" : "log")
378
+ };
876
379
  }
877
- function configGlobal(options) {
878
- if (_standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.configured) {
879
- const log = _standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl.standardLog.getLogger('standard-log');
880
- log.warn('configGlobal() is being called more than once. Please make sure this is expected. Application should use `createStandardLog()` most of the time.');
881
- }
882
- if (_standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl) {
883
- if (options.logLevel) {
884
- _standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl.store.logLevel = options.logLevel;
885
- }
886
- if (options.reporters) {
887
- const reporters = _standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl.store.reporters;
888
- reporters.length = 0;
889
- reporters.push(...options.reporters);
890
- }
891
- }
892
- else {
893
- _standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.gsl = createStandardLogClosure(options);
894
- }
895
- _standard_log_ctx_js__WEBPACK_IMPORTED_MODULE_5__.ctx.configured = true;
380
+ // istanbul ignore next
381
+ function buildFn(name) {
382
+ return (...args) => {
383
+ console[name](...args);
384
+ };
896
385
  }
897
-
898
-
899
- /***/ },
900
-
901
- /***/ "../../node_modules/.pnpm/iso-error@6.0.3/node_modules/iso-error/esm/index.js"
902
- /*!************************************************************************************!*\
903
- !*** ../../node_modules/.pnpm/iso-error@6.0.3/node_modules/iso-error/esm/index.js ***!
904
- \************************************************************************************/
905
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
906
-
907
- "use strict";
908
- __webpack_require__.r(__webpack_exports__);
909
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
910
- /* harmony export */ IsoError: function() { return /* binding */ IsoError; },
911
- /* harmony export */ ModuleError: function() { return /* binding */ ModuleError; },
912
- /* harmony export */ SerializableConverter: function() { return /* binding */ SerializableConverter; },
913
- /* harmony export */ isAggregateError: function() { return /* binding */ isAggregateError; }
914
- /* harmony export */ });
915
- var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
916
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
917
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
918
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
386
+ function createConsoleLogReporter(options) {
387
+ const { id, formatter, filter } = unpartial({
388
+ id: "console",
389
+ formatter: consoleFormatter
390
+ }, options);
391
+ if (!polyfill.console) polyfill.console = buildPolyfillConsole();
392
+ return Object.freeze({
393
+ id,
394
+ isConsoleReporter: true,
395
+ get formatter() {
396
+ return formatter;
397
+ },
398
+ get filter() {
399
+ return filter;
400
+ },
401
+ console: polyfill.console,
402
+ write(entry) {
403
+ if (filter && !filter(entry)) return;
404
+ const values = formatter(entry);
405
+ const method = toConsoleMethod(entry.level);
406
+ this.console[method](...values);
407
+ }
408
+ });
409
+ }
410
+ //#endregion
411
+ //#region ../../node_modules/.pnpm/iso-error@6.0.3/node_modules/iso-error/esm/index.js
412
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
413
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
414
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
415
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
919
416
  };
920
- var _a, _IsoError_hasCause, _IsoError_toIsoError;
921
- //#region captureStackTrace polyfill
417
+ var _a;
418
+ var _IsoError_hasCause;
419
+ var _IsoError_toIsoError;
922
420
  // istanbul ignore next
923
- if (!Error.captureStackTrace) {
924
- Error.captureStackTrace = function (error) {
925
- const container = new Error();
926
- Object.defineProperty(error, 'stack', {
927
- configurable: true,
928
- get: function () {
929
- // Replace property with value for faster future accesses.
930
- defineStack(this, container.stack);
931
- return container.stack;
932
- },
933
- set: function (stack) {
934
- defineStack(error, stack);
935
- }
936
- });
937
- };
938
- }
421
+ if (!Error.captureStackTrace) Error.captureStackTrace = function(error) {
422
+ const container = /* @__PURE__ */ new Error();
423
+ Object.defineProperty(error, "stack", {
424
+ configurable: true,
425
+ get: function() {
426
+ defineStack(this, container.stack);
427
+ return container.stack;
428
+ },
429
+ set: function(stack) {
430
+ defineStack(error, stack);
431
+ }
432
+ });
433
+ };
939
434
  // istanbul ignore next
940
435
  function defineStack(target, value) {
941
- Object.defineProperty(target, 'stack', {
942
- configurable: true,
943
- value,
944
- writable: true
945
- });
946
- }
947
- class SerializableConverter {
948
- constructor() {
949
- Object.defineProperty(this, "plugins", {
950
- enumerable: true,
951
- configurable: true,
952
- writable: true,
953
- value: []
954
- });
955
- }
956
- addPlugin(plugin) {
957
- this.plugins.unshift(plugin);
958
- }
959
- /**
960
- * Deserialize an `Error` from `Serializable`
961
- */
962
- fromSerializable(json, options) {
963
- const err = this.deserializeError(json);
964
- Error.captureStackTrace(err, options?.ssf);
965
- return err;
966
- }
967
- fromSerializableImpl(json) {
968
- if (json['name'] === 'AggregateError') {
969
- const { message, errors, ...rest } = json;
970
- // @ts-ignore
971
- // istanbul ignore next
972
- if (__webpack_require__.g.AggregateError) {
973
- return Object.assign(new AggregateError(errors, message), rest);
974
- }
975
- else {
976
- return Object.assign(new Error(message), {
977
- ...rest,
978
- errors
979
- });
980
- }
981
- }
982
- const { message, cause, ...rest } = json;
983
- const causeError = cause ? this.deserializeError(cause) : undefined;
984
- if (json['name'] === 'Error') {
985
- return Object.assign(new Error(message), causeError ? { ...rest, cause: causeError } : rest);
986
- }
987
- // @ts-ignore
988
- return Object.assign(new IsoError(message, causeError ? { cause: causeError } : undefined), rest);
989
- }
990
- deserializeError(json) {
991
- let err = undefined;
992
- for (const { fromSerializable } of this.plugins) {
993
- err = fromSerializable(json);
994
- if (err)
995
- break;
996
- }
997
- return err || this.fromSerializableImpl(json);
998
- }
999
- /**
1000
- * Serialize `Error` to `Serializable`
1001
- */
1002
- toSerializable(err) {
1003
- return (this.plugins.reduce((p, s) => p || s.toSerializable(err), undefined) || this.toSerializableImpl(err));
1004
- }
1005
- toSerializableImpl(err) {
1006
- if (isAggregateError(err)) {
1007
- return {
1008
- ...err,
1009
- name: err.constructor.name,
1010
- message: err.message,
1011
- errors: err.errors.map(this.toSerializableImpl)
1012
- };
1013
- }
1014
- if (err instanceof Error) {
1015
- const { message, cause } = err;
1016
- return cause
1017
- ? { ...err, name: err.constructor.name, message, cause: this.toSerializableImpl(cause) }
1018
- : { ...err, name: err.constructor.name, message };
1019
- }
1020
- return err;
1021
- }
1022
- }
436
+ Object.defineProperty(target, "stack", {
437
+ configurable: true,
438
+ value,
439
+ writable: true
440
+ });
441
+ }
442
+ var SerializableConverter = class {
443
+ constructor() {
444
+ Object.defineProperty(this, "plugins", {
445
+ enumerable: true,
446
+ configurable: true,
447
+ writable: true,
448
+ value: []
449
+ });
450
+ }
451
+ addPlugin(plugin) {
452
+ this.plugins.unshift(plugin);
453
+ }
454
+ /**
455
+ * Deserialize an `Error` from `Serializable`
456
+ */
457
+ fromSerializable(json, options) {
458
+ const err = this.deserializeError(json);
459
+ Error.captureStackTrace(err, options?.ssf);
460
+ return err;
461
+ }
462
+ fromSerializableImpl(json) {
463
+ if (json["name"] === "AggregateError") {
464
+ const { message, errors, ...rest } = json;
465
+ // istanbul ignore next
466
+ if (global.AggregateError) return Object.assign(new AggregateError(errors, message), rest);
467
+ else return Object.assign(new Error(message), {
468
+ ...rest,
469
+ errors
470
+ });
471
+ }
472
+ const { message, cause, ...rest } = json;
473
+ const causeError = cause ? this.deserializeError(cause) : void 0;
474
+ if (json["name"] === "Error") return Object.assign(new Error(message), causeError ? {
475
+ ...rest,
476
+ cause: causeError
477
+ } : rest);
478
+ return Object.assign(new IsoError(message, causeError ? { cause: causeError } : void 0), rest);
479
+ }
480
+ deserializeError(json) {
481
+ let err = void 0;
482
+ for (const { fromSerializable } of this.plugins) {
483
+ err = fromSerializable(json);
484
+ if (err) break;
485
+ }
486
+ return err || this.fromSerializableImpl(json);
487
+ }
488
+ /**
489
+ * Serialize `Error` to `Serializable`
490
+ */
491
+ toSerializable(err) {
492
+ return this.plugins.reduce((p, s) => p || s.toSerializable(err), void 0) || this.toSerializableImpl(err);
493
+ }
494
+ toSerializableImpl(err) {
495
+ if (isAggregateError(err)) return {
496
+ ...err,
497
+ name: err.constructor.name,
498
+ message: err.message,
499
+ errors: err.errors.map(this.toSerializableImpl)
500
+ };
501
+ if (err instanceof Error) {
502
+ const { message, cause } = err;
503
+ return cause ? {
504
+ ...err,
505
+ name: err.constructor.name,
506
+ message,
507
+ cause: this.toSerializableImpl(cause)
508
+ } : {
509
+ ...err,
510
+ name: err.constructor.name,
511
+ message
512
+ };
513
+ }
514
+ return err;
515
+ }
516
+ };
1023
517
  const getCircularReplacer = () => {
1024
- const seen = new WeakSet();
1025
- return (_, value) => {
1026
- if (typeof value === 'object' && value !== null) {
1027
- if (seen.has(value)) {
1028
- return;
1029
- }
1030
- seen.add(value);
1031
- }
1032
- return value;
1033
- };
518
+ const seen = /* @__PURE__ */ new WeakSet();
519
+ return (_, value) => {
520
+ if (typeof value === "object" && value !== null) {
521
+ if (seen.has(value)) return;
522
+ seen.add(value);
523
+ }
524
+ return value;
525
+ };
1034
526
  };
1035
527
  /**
1036
- * Isomorphic Error that works across physical boundary.
1037
- */
1038
- class IsoError extends Error {
1039
- /**
1040
- * Create an IsoError with additional properties without the need to create a new class.
1041
- * @param props properties of the IsoError
1042
- */
1043
- static create(props) {
1044
- const { message, cause, ...rest } = props;
1045
- const err = new IsoError(message, { cause, ssf: IsoError.create });
1046
- return Object.assign(err, rest);
1047
- }
1048
- static stringify(err) {
1049
- return this.serialize(err);
1050
- }
1051
- static serialize(err) {
1052
- return JSON.stringify(this.toSerializable(err), getCircularReplacer());
1053
- }
1054
- static toSerializable(err) {
1055
- return this.converter.toSerializable(err);
1056
- }
1057
- /**
1058
- * @type P Additional properties of the IsoError
1059
- * @param text Json representation of a IsoError
1060
- */
1061
- static parse(text) {
1062
- const json = JSON.parse(text);
1063
- return this.converter.fromSerializable(json, { ssf: IsoError.parse });
1064
- }
1065
- /**
1066
- * @type P Additional properties of the IsoError
1067
- * @param text Json representation of a IsoError
1068
- */
1069
- static deserialize(text) {
1070
- const json = JSON.parse(text);
1071
- return this.converter.fromSerializable(json, { ssf: IsoError.deserialize });
1072
- }
1073
- static fromSerializable(json) {
1074
- return this.converter.fromSerializable(json, { ssf: IsoError.fromSerializable });
1075
- }
1076
- /**
1077
- * returns the error message including the error causes.
1078
- */
1079
- static trace(err) {
1080
- const messages = [];
1081
- if (err instanceof ModuleError) {
1082
- messages.push(`${err.name}(${err.module}): ${err.message}`);
1083
- }
1084
- else if (err instanceof Error) {
1085
- messages.push(`${err.name}: ${err.message}`);
1086
- }
1087
- if (isAggregateError(err)) {
1088
- err.errors.forEach(e => messages.push(...this.trace(e)
1089
- .split('\n')
1090
- .map(s => ' ' + s)));
1091
- }
1092
- if (err instanceof Error) {
1093
- if (__classPrivateFieldGet(this, _a, "m", _IsoError_hasCause).call(this, err))
1094
- messages.push(...this.trace(err.cause)
1095
- .split('\n')
1096
- .map(s => ' ' + s));
1097
- }
1098
- else {
1099
- messages.push(typeof err === 'string' ? err : JSON.stringify(err));
1100
- }
1101
- return messages.join('\n');
1102
- }
1103
- static addPlugin(plugin) {
1104
- this.converter.addPlugin(plugin);
1105
- }
1106
- constructor(message, options) {
1107
- super(message);
1108
- /**
1109
- * Name of the error
1110
- */
1111
- Object.defineProperty(this, "name", {
1112
- enumerable: true,
1113
- configurable: true,
1114
- writable: true,
1115
- value: void 0
1116
- });
1117
- /**
1118
- * Error cause
1119
- */
1120
- Object.defineProperty(this, "cause", {
1121
- enumerable: true,
1122
- configurable: true,
1123
- writable: true,
1124
- value: void 0
1125
- });
1126
- // restore prototype chain
1127
- const actualProto = new.target.prototype;
1128
- this.name = actualProto.constructor.name;
1129
- // istanbul ignore next
1130
- if (Object.setPrototypeOf)
1131
- Object.setPrototypeOf(this, actualProto);
1132
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1133
- else
1134
- this.__proto__ = actualProto;
1135
- if (options?.cause)
1136
- this.cause = __classPrivateFieldGet(IsoError, _a, "m", _IsoError_toIsoError).call(IsoError, options.cause);
1137
- if (options?.ssf)
1138
- Error.captureStackTrace(this, options.ssf);
1139
- }
1140
- toString() {
1141
- return IsoError.serialize(this);
1142
- }
1143
- trace() {
1144
- return IsoError.trace(this);
1145
- }
1146
- }
528
+ * Isomorphic Error that works across physical boundary.
529
+ */
530
+ var IsoError = class IsoError extends Error {
531
+ /**
532
+ * Create an IsoError with additional properties without the need to create a new class.
533
+ * @param props properties of the IsoError
534
+ */
535
+ static create(props) {
536
+ const { message, cause, ...rest } = props;
537
+ const err = new IsoError(message, {
538
+ cause,
539
+ ssf: IsoError.create
540
+ });
541
+ return Object.assign(err, rest);
542
+ }
543
+ static stringify(err) {
544
+ return this.serialize(err);
545
+ }
546
+ static serialize(err) {
547
+ return JSON.stringify(this.toSerializable(err), getCircularReplacer());
548
+ }
549
+ static toSerializable(err) {
550
+ return this.converter.toSerializable(err);
551
+ }
552
+ /**
553
+ * @type P Additional properties of the IsoError
554
+ * @param text Json representation of a IsoError
555
+ */
556
+ static parse(text) {
557
+ const json = JSON.parse(text);
558
+ return this.converter.fromSerializable(json, { ssf: IsoError.parse });
559
+ }
560
+ /**
561
+ * @type P Additional properties of the IsoError
562
+ * @param text Json representation of a IsoError
563
+ */
564
+ static deserialize(text) {
565
+ const json = JSON.parse(text);
566
+ return this.converter.fromSerializable(json, { ssf: IsoError.deserialize });
567
+ }
568
+ static fromSerializable(json) {
569
+ return this.converter.fromSerializable(json, { ssf: IsoError.fromSerializable });
570
+ }
571
+ /**
572
+ * returns the error message including the error causes.
573
+ */
574
+ static trace(err) {
575
+ const messages = [];
576
+ if (err instanceof ModuleError) messages.push(`${err.name}(${err.module}): ${err.message}`);
577
+ else if (err instanceof Error) messages.push(`${err.name}: ${err.message}`);
578
+ if (isAggregateError(err)) err.errors.forEach((e) => messages.push(...this.trace(e).split("\n").map((s) => " " + s)));
579
+ if (err instanceof Error) {
580
+ if (__classPrivateFieldGet(this, _a, "m", _IsoError_hasCause).call(this, err)) messages.push(...this.trace(err.cause).split("\n").map((s) => " " + s));
581
+ } else messages.push(typeof err === "string" ? err : JSON.stringify(err));
582
+ return messages.join("\n");
583
+ }
584
+ static addPlugin(plugin) {
585
+ this.converter.addPlugin(plugin);
586
+ }
587
+ constructor(message, options) {
588
+ super(message);
589
+ /**
590
+ * Name of the error
591
+ */
592
+ Object.defineProperty(this, "name", {
593
+ enumerable: true,
594
+ configurable: true,
595
+ writable: true,
596
+ value: void 0
597
+ });
598
+ /**
599
+ * Error cause
600
+ */
601
+ Object.defineProperty(this, "cause", {
602
+ enumerable: true,
603
+ configurable: true,
604
+ writable: true,
605
+ value: void 0
606
+ });
607
+ const actualProto = new.target.prototype;
608
+ this.name = actualProto.constructor.name;
609
+ // istanbul ignore next
610
+ if (Object.setPrototypeOf) Object.setPrototypeOf(this, actualProto);
611
+ else this.__proto__ = actualProto;
612
+ if (options?.cause) this.cause = __classPrivateFieldGet(IsoError, _a, "m", _IsoError_toIsoError).call(IsoError, options.cause);
613
+ if (options?.ssf) Error.captureStackTrace(this, options.ssf);
614
+ }
615
+ toString() {
616
+ return IsoError.serialize(this);
617
+ }
618
+ trace() {
619
+ return IsoError.trace(this);
620
+ }
621
+ };
1147
622
  _a = IsoError, _IsoError_hasCause = function _IsoError_hasCause(x) {
1148
- return !!x.cause;
623
+ return !!x.cause;
1149
624
  }, _IsoError_toIsoError = function _IsoError_toIsoError(err) {
1150
- // When the error is an internal error from deserialization,
1151
- // the err.constructor.name is object.
1152
- // I have to to Object.assign to keep the err instance and its stack trace.
1153
- return Object.assign(err, { name: err.name ?? err.constructor.name });
625
+ return Object.assign(err, { name: err.name ?? err.constructor.name });
1154
626
  };
1155
627
  Object.defineProperty(IsoError, "converter", {
1156
- enumerable: true,
1157
- configurable: true,
1158
- writable: true,
1159
- value: new SerializableConverter()
628
+ enumerable: true,
629
+ configurable: true,
630
+ writable: true,
631
+ value: new SerializableConverter()
1160
632
  });
1161
-
1162
633
  /**
1163
- * An IsoError with a module property.
1164
- */
1165
- class ModuleError extends IsoError {
1166
- /**
1167
- * @param module The module that defines this error.
1168
- */
1169
- constructor(module, message, options) {
1170
- super(message, options);
1171
- Object.defineProperty(this, "module", {
1172
- enumerable: true,
1173
- configurable: true,
1174
- writable: true,
1175
- value: module
1176
- });
1177
- }
1178
- }
634
+ * An IsoError with a module property.
635
+ */
636
+ var ModuleError = class extends IsoError {
637
+ /**
638
+ * @param module The module that defines this error.
639
+ */
640
+ constructor(module, message, options) {
641
+ super(message, options);
642
+ Object.defineProperty(this, "module", {
643
+ enumerable: true,
644
+ configurable: true,
645
+ writable: true,
646
+ value: module
647
+ });
648
+ }
649
+ };
1179
650
  function isAggregateError(error) {
1180
- return error instanceof Error && Array.isArray(error.errors);
651
+ return error instanceof Error && Array.isArray(error.errors);
1181
652
  }
1182
- //# sourceMappingURL=index.js.map
1183
-
1184
- /***/ },
1185
-
1186
- /***/ "../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/mapKey.js"
1187
- /*!********************************************************************************************!*\
1188
- !*** ../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/mapKey.js ***!
1189
- \********************************************************************************************/
1190
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1191
-
1192
- "use strict";
1193
- __webpack_require__.r(__webpack_exports__);
1194
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1195
- /* harmony export */ mapKey: function() { return /* binding */ mapKey; }
1196
- /* harmony export */ });
1197
- function mapKey(subject, predicate, thisArg) {
1198
- return Object.keys(subject).map(function (k, i, a) {
1199
- return predicate.apply(this, [k, i, a, subject]);
1200
- }, thisArg);
653
+ //#endregion
654
+ //#region ts/errors.ts
655
+ /**
656
+ * @deprecated No longer used since 11.2.0
657
+ */
658
+ var StandardLogError = class extends ModuleError {
659
+ constructor(description, options) {
660
+ super("standard-log", description, options);
661
+ }
662
+ };
663
+ /**
664
+ * @deprecated no longer used since 11.2.0
665
+ */
666
+ var InvalidId = class extends StandardLogError {
667
+ id;
668
+ constructor(id, options) {
669
+ super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options);
670
+ this.id = id;
671
+ }
672
+ };
673
+ //#endregion
674
+ //#region ts/memory.ts
675
+ function toMessageWithLevel(logs) {
676
+ return logs.map(toInspectLogEntry).map((log) => `${formatLogLevel(log.level)} ${log.args.join(" ")}`).join("\n").replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, "");
1201
677
  }
1202
- //# sourceMappingURL=mapKey.js.map
1203
-
1204
- /***/ },
1205
-
1206
- /***/ "../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/record.js"
1207
- /*!********************************************************************************************!*\
1208
- !*** ../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/record.js ***!
1209
- \********************************************************************************************/
1210
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1211
-
1212
- "use strict";
1213
- __webpack_require__.r(__webpack_exports__);
1214
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1215
- /* harmony export */ record: function() { return /* binding */ record; }
1216
- /* harmony export */ });
1217
- function record(value) {
1218
- const r = Object.create(null);
1219
- return (value ? Object.assign(r, value) : r);
678
+ function createMemoryLogReporter(options) {
679
+ return Object.freeze(buildMemoryReporter(unpartial({ id: "memory" }, options)));
1220
680
  }
1221
- //# sourceMappingURL=record.js.map
1222
-
1223
- /***/ },
1224
-
1225
- /***/ "../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/reduceKey.js"
1226
- /*!***********************************************************************************************!*\
1227
- !*** ../../node_modules/.pnpm/type-plus@7.6.2/node_modules/type-plus/esm/object/reduceKey.js ***!
1228
- \***********************************************************************************************/
1229
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1230
-
1231
- "use strict";
1232
- __webpack_require__.r(__webpack_exports__);
1233
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1234
- /* harmony export */ reduceByKey: function() { return /* binding */ reduceByKey; },
1235
- /* harmony export */ reduceKey: function() { return /* binding */ reduceKey; }
1236
- /* harmony export */ });
1237
- function reduceByKey(subject, callbackfn, initialValue) {
1238
- return Object.keys(subject).reduce((p, k, i, a) => callbackfn(p, k, i, a, subject), initialValue);
681
+ function buildMemoryReporter(options) {
682
+ const { id, formatter, filter } = required({
683
+ id: "memory",
684
+ formatter: (e) => e
685
+ }, options);
686
+ const logs = [];
687
+ return {
688
+ id,
689
+ get formatter() {
690
+ return formatter;
691
+ },
692
+ get filter() {
693
+ return filter;
694
+ },
695
+ logs,
696
+ write(entry) {
697
+ if (filter && !filter(entry)) return;
698
+ logs.push(formatter(entry));
699
+ },
700
+ getLogMessage() {
701
+ return this.getLogMessages().join("\n");
702
+ },
703
+ getLogMessages() {
704
+ return logs.map(toInspectLogEntry).map((log) => log.args.join(" "));
705
+ },
706
+ getLogMessagesWithLevel() {
707
+ return logs.map(toInspectLogEntry).map((log) => `${formatLogLevel(log.level)} ${log.args.join(" ")}`);
708
+ },
709
+ getLogMessagesWithIdAndLevel() {
710
+ return logs.map(toInspectLogEntry).map((log) => `${log.id} ${formatLogLevel(log.level)} ${log.args.join(" ")}`);
711
+ },
712
+ getLogMessageWithLevel() {
713
+ return toMessageWithLevel(logs);
714
+ },
715
+ /**
716
+ * emit the saved log to console for easy debugging
717
+ */
718
+ emit() {
719
+ const reporter = createConsoleLogReporter();
720
+ logs.forEach((l) => reporter.write(l));
721
+ }
722
+ };
1239
723
  }
1240
- /**
1241
- * @deprecated renamed to reduceByKey
1242
- */
1243
- const reduceKey = reduceByKey;
1244
- //# sourceMappingURL=reduceKey.js.map
1245
-
1246
- /***/ },
1247
-
1248
- /***/ "../../node_modules/.pnpm/unpartial@1.0.5/node_modules/unpartial/esm/index.js"
1249
- /*!************************************************************************************!*\
1250
- !*** ../../node_modules/.pnpm/unpartial@1.0.5/node_modules/unpartial/esm/index.js ***!
1251
- \************************************************************************************/
1252
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1253
-
1254
- "use strict";
1255
- __webpack_require__.r(__webpack_exports__);
1256
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1257
- /* harmony export */ required: function() { return /* binding */ required; },
1258
- /* harmony export */ requiredDeep: function() { return /* binding */ requiredDeep; },
1259
- /* harmony export */ unpartial: function() { return /* binding */ unpartial; },
1260
- /* harmony export */ unpartialRecursively: function() { return /* binding */ unpartialRecursively; }
1261
- /* harmony export */ });
1262
- function required(source1, source2, source3) {
1263
- return merge([source1, source2, source3], (p, e) => {
1264
- return { ...p, ...e };
1265
- });
724
+ function createMemoryWithConsoleLogReporter(options) {
725
+ return Object.freeze(Object.assign(buildMemoryReporter(unpartial({ id: "memory-with-console" }, options)), { isConsoleReporter: true }));
1266
726
  }
1267
- function requiredDeep(source1, source2, source3) {
1268
- return merge([source1, source2, source3], (p, e) => deepmerge(p, e));
727
+ //#endregion
728
+ //#region ts/log_store.ts
729
+ function createLogStore(options) {
730
+ return {
731
+ loggers: record(),
732
+ nonConsoleLoggers: record(),
733
+ reporters: options.reporters || [createConsoleLogReporter()],
734
+ logLevel: options.logLevel,
735
+ logLevelStore: logLevelStore(options)
736
+ };
1269
737
  }
1270
- function merge(entries, reducer) {
1271
- if (entries[0] === undefined || entries[0] === null)
1272
- return entries[0];
1273
- return entries.filter(x => !!x).reduce(reducer, {});
738
+ function logLevelStore(options) {
739
+ const customLevels = options.customLevels || record();
740
+ const store = {
741
+ customLevels,
742
+ customLevelsReverse: reduceByKey(customLevels, (p, k) => {
743
+ p[customLevels[k]] = k;
744
+ return p;
745
+ }, {})
746
+ };
747
+ return {
748
+ getName(level) {
749
+ return store.customLevelsReverse[level] ?? toLogLevelName(level);
750
+ },
751
+ getLevel(name) {
752
+ return store.customLevels[name] ?? toLogLevel(name);
753
+ },
754
+ getAllLevels() {
755
+ return reduceKey(logLevels, (result, name) => {
756
+ if (name !== "none" && name !== "all") result.push({
757
+ name,
758
+ level: logLevels[name]
759
+ });
760
+ return result;
761
+ }, mapKey(store.customLevels, (name) => ({
762
+ name,
763
+ level: store.customLevels[name]
764
+ })));
765
+ }
766
+ };
767
+ }
768
+ //#endregion
769
+ //#region ts/logger.ts
770
+ function createLogger(store, id, options) {
771
+ id = sanitizeId(id);
772
+ const writeTo = options?.writeTo ?? (() => true);
773
+ const [filter, reporters] = typeof writeTo === "string" ? [(id) => id === writeTo, store.reporters] : writeTo instanceof RegExp ? [(id) => writeTo.test(id), store.reporters] : typeof writeTo === "function" ? [writeTo, store.reporters] : [() => true, [writeTo]];
774
+ function write(entry) {
775
+ writeToReporters(reporters, entry, filter);
776
+ }
777
+ const logger = {
778
+ level: options?.level,
779
+ write
780
+ };
781
+ Object.defineProperties(logger, {
782
+ id: {
783
+ value: id,
784
+ writable: false
785
+ },
786
+ count: {
787
+ writable: false,
788
+ value: ((counter) => (...args) => {
789
+ if (shouldLog(store, logLevels.debug, logger.level)) write({
790
+ id,
791
+ level: logLevels.debug,
792
+ args: [++counter, ...args],
793
+ timestamp: /* @__PURE__ */ new Date()
794
+ });
795
+ })(0)
796
+ },
797
+ on: {
798
+ writable: false,
799
+ value: (level, logFn) => {
800
+ const logLevel = typeof level === "string" ? store.logLevelStore.getLevel(level) : level;
801
+ if (shouldLog(store, logLevel, logger.level)) {
802
+ const methodName = store.logLevelStore.getName(logLevel);
803
+ const bindedMethod = logger[methodName].bind(logger);
804
+ const result = logFn(bindedMethod, logger.level ?? store.logLevel);
805
+ if (result) bindedMethod(result);
806
+ }
807
+ }
808
+ }
809
+ });
810
+ store.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {
811
+ Object.defineProperty(logger, name, {
812
+ writable: false,
813
+ value: (...args) => {
814
+ if (shouldLog(store, level, logger.level)) write({
815
+ id,
816
+ level,
817
+ args,
818
+ timestamp: /* @__PURE__ */ new Date()
819
+ });
820
+ }
821
+ });
822
+ });
823
+ return logger;
1274
824
  }
1275
- function deepmerge(source1, source2) {
1276
- if (typeof source1 !== 'object' || source1 === null)
1277
- return source2 !== undefined ? source2 : source1;
1278
- if (Array.isArray(source1)) {
1279
- if (Array.isArray(source2))
1280
- return source2;
1281
- if (source2 === undefined)
1282
- return [...source1];
1283
- return [...source1, source2];
1284
- }
1285
- return getAllKeys(source1).concat(getAllKeys(source2)).reduce((p, k) => {
1286
- // @ts-ignore
1287
- p[k] = deepmerge(source1[k], source2 && source2[k]);
1288
- return p;
1289
- }, {});
825
+ function sanitizeId(id) {
826
+ return id.replace(/[`~!#$%^&*()=+[\]{},|<>?]/g, "-");
1290
827
  }
1291
- function getAllKeys(subject, internal = false) {
1292
- if (typeof subject !== 'object')
1293
- return [];
1294
- const propertyNames = Object.getOwnPropertyNames(subject);
1295
- const keys = internal ? propertyNames.filter(n => n !== 'constructor') : propertyNames;
1296
- const proto = Object.getPrototypeOf(subject);
1297
- return proto !== Object.prototype ? keys.concat(getAllKeys(proto, true)) : keys;
828
+ function writeToReporters(reporters, logEntry, filter) {
829
+ reporters.filter((r) => filter(r.id)).forEach((r) => r.write(logEntry));
1298
830
  }
1299
- function unpartial(s1, s2, s3) {
1300
- // defensive check for JS
1301
- if (s1 === undefined || s1 === null)
1302
- return s1;
1303
- return [s1, s2, s3]
1304
- .filter(notNil)
1305
- .reduce((p, s) => ({ ...p, ...trimNilProps(s) }), {});
831
+ /**
832
+ * Determines should you log.
833
+ * @param loggerLevel Log level of the logger.
834
+ * It can be undefined which the global log level will be used.
835
+ */
836
+ function shouldLog(store, targetLevel, loggerLevel) {
837
+ return targetLevel <= (loggerLevel !== void 0 ? loggerLevel : store.logLevel);
1306
838
  }
1307
- function trimNilProps(value) {
1308
- return Object.keys(value).reduce((p, k) => {
1309
- if (notNil(value[k]))
1310
- p[k] = value[k];
1311
- return p;
1312
- }, {});
839
+ //#endregion
840
+ //#region ts/standard_log.ctx.ts
841
+ const ctx = record();
842
+ //#endregion
843
+ //#region ts/standard_log.ts
844
+ function createStandardLog(options) {
845
+ const closure = createStandardLogClosure(options);
846
+ if (options?.reporters?.some((r) => !r.id)) closure.standardLog.getLogger("standard-log").critical(`Detected reporter with empty id. This is not allowed as it will create problems with feature like 'getNonConsoleLogger()'. Please add an id to your reporter.`);
847
+ if (!ctx.gsl) ctx.gsl = closure;
848
+ return closure.standardLog;
1313
849
  }
1314
- function notNil(value) {
1315
- return value !== null && value !== undefined;
850
+ function noop() {}
851
+ function createStandardLogClosure(options) {
852
+ const store = createLogStore(required({ logLevel: logLevels.info }, options));
853
+ const nonConsoleReporters = options?.reporters?.filter((r) => !r.isConsoleReporter).map((r) => r.id) ?? [];
854
+ const logMethods = DEFAULT_LOG_METHOD_NAMES.concat(Object.keys(options?.customLevels ?? {})).concat([
855
+ "on",
856
+ "count",
857
+ "write"
858
+ ]);
859
+ return {
860
+ store,
861
+ standardLog: {
862
+ get logLevel() {
863
+ return store.logLevel;
864
+ },
865
+ toLogLevelName(level) {
866
+ return store.logLevelStore.getName(level);
867
+ },
868
+ toLogLevel(name) {
869
+ return store.logLevelStore.getLevel(name);
870
+ },
871
+ getLogger(id, options) {
872
+ if (store.loggers[id]) return store.loggers[id];
873
+ return store.loggers[id] = createLogger(store, id, {
874
+ ssf: this.getLogger,
875
+ ...options
876
+ });
877
+ },
878
+ getNonConsoleLogger(id, options) {
879
+ if (store.nonConsoleLoggers[id]) return store.nonConsoleLoggers[id];
880
+ if (store.loggers[id]) {
881
+ this.getLogger("standard-log").warn(`attempt to create a non-console logger with existing id ('${id}'), ignoring`);
882
+ return store.nonConsoleLoggers[id] = createDummyLogger(logMethods);
883
+ }
884
+ return store.nonConsoleLoggers[id] = nonConsoleReporters.length === 0 ? createDummyLogger(logMethods) : createLogger(store, id, {
885
+ ssf: this.getNonConsoleLogger,
886
+ ...options,
887
+ writeTo(reporterId) {
888
+ return nonConsoleReporters.indexOf(reporterId) >= 0;
889
+ }
890
+ });
891
+ }
892
+ }
893
+ };
1316
894
  }
1317
- function unpartialRecursively(arg1, arg2, arg3) {
1318
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1319
- return requiredDeep(arg1, arg2, arg3);
895
+ function createDummyLogger(logMethods) {
896
+ return logMethods.reduce((p, m) => {
897
+ p[m] = noop;
898
+ return p;
899
+ }, record());
1320
900
  }
1321
- //# sourceMappingURL=index.js.map
1322
-
1323
- /***/ }
1324
-
1325
- /******/ });
1326
- /************************************************************************/
1327
- /******/ // The module cache
1328
- /******/ var __webpack_module_cache__ = {};
1329
- /******/
1330
- /******/ // The require function
1331
- /******/ function __webpack_require__(moduleId) {
1332
- /******/ // Check if module is in cache
1333
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
1334
- /******/ if (cachedModule !== undefined) {
1335
- /******/ return cachedModule.exports;
1336
- /******/ }
1337
- /******/ // Create a new module (and put it into the cache)
1338
- /******/ var module = __webpack_module_cache__[moduleId] = {
1339
- /******/ // no module.id needed
1340
- /******/ // no module.loaded needed
1341
- /******/ exports: {}
1342
- /******/ };
1343
- /******/
1344
- /******/ // Execute the module function
1345
- /******/ if (!(moduleId in __webpack_modules__)) {
1346
- /******/ delete __webpack_module_cache__[moduleId];
1347
- /******/ var e = new Error("Cannot find module '" + moduleId + "'");
1348
- /******/ e.code = 'MODULE_NOT_FOUND';
1349
- /******/ throw e;
1350
- /******/ }
1351
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1352
- /******/
1353
- /******/ // Return the exports of the module
1354
- /******/ return module.exports;
1355
- /******/ }
1356
- /******/
1357
- /************************************************************************/
1358
- /******/ /* webpack/runtime/compat get default export */
1359
- /******/ !function() {
1360
- /******/ // getDefaultExport function for compatibility with non-harmony modules
1361
- /******/ __webpack_require__.n = function(module) {
1362
- /******/ var getter = module && module.__esModule ?
1363
- /******/ function() { return module['default']; } :
1364
- /******/ function() { return module; };
1365
- /******/ __webpack_require__.d(getter, { a: getter });
1366
- /******/ return getter;
1367
- /******/ };
1368
- /******/ }();
1369
- /******/
1370
- /******/ /* webpack/runtime/define property getters */
1371
- /******/ !function() {
1372
- /******/ // define getter functions for harmony exports
1373
- /******/ __webpack_require__.d = function(exports, definition) {
1374
- /******/ for(var key in definition) {
1375
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1376
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1377
- /******/ }
1378
- /******/ }
1379
- /******/ };
1380
- /******/ }();
1381
- /******/
1382
- /******/ /* webpack/runtime/global */
1383
- /******/ !function() {
1384
- /******/ __webpack_require__.g = (function() {
1385
- /******/ if (typeof globalThis === 'object') return globalThis;
1386
- /******/ try {
1387
- /******/ return this || new Function('return this')();
1388
- /******/ } catch (e) {
1389
- /******/ if (typeof window === 'object') return window;
1390
- /******/ }
1391
- /******/ })();
1392
- /******/ }();
1393
- /******/
1394
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
1395
- /******/ !function() {
1396
- /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
1397
- /******/ }();
1398
- /******/
1399
- /******/ /* webpack/runtime/make namespace object */
1400
- /******/ !function() {
1401
- /******/ // define __esModule on exports
1402
- /******/ __webpack_require__.r = function(exports) {
1403
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1404
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1405
- /******/ }
1406
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
1407
- /******/ };
1408
- /******/ }();
1409
- /******/
1410
- /************************************************************************/
1411
- var __webpack_exports__ = {};
1412
- // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
1413
- !function() {
1414
- "use strict";
1415
- /*!*********************!*\
1416
- !*** ./ts/index.ts ***!
1417
- \*********************/
1418
- __webpack_require__.r(__webpack_exports__);
1419
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1420
- /* harmony export */ DEFAULT_LOG_METHOD_NAMES: function() { return /* reexport safe */ _log_levels_js__WEBPACK_IMPORTED_MODULE_3__.DEFAULT_LOG_METHOD_NAMES; },
1421
- /* harmony export */ InvalidId: function() { return /* reexport safe */ _errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidId; },
1422
- /* harmony export */ StandardLogError: function() { return /* reexport safe */ _errors_js__WEBPACK_IMPORTED_MODULE_1__.StandardLogError; },
1423
- /* harmony export */ configGlobal: function() { return /* reexport safe */ _standard_log_js__WEBPACK_IMPORTED_MODULE_5__.configGlobal; },
1424
- /* harmony export */ consoleFormatter: function() { return /* reexport safe */ _formatter_js__WEBPACK_IMPORTED_MODULE_2__.consoleFormatter; },
1425
- /* harmony export */ createConsoleLogReporter: function() { return /* reexport safe */ _console_js__WEBPACK_IMPORTED_MODULE_0__.createConsoleLogReporter; },
1426
- /* harmony export */ createMemoryLogReporter: function() { return /* reexport safe */ _memory_js__WEBPACK_IMPORTED_MODULE_4__.createMemoryLogReporter; },
1427
- /* harmony export */ createMemoryWithConsoleLogReporter: function() { return /* reexport safe */ _memory_js__WEBPACK_IMPORTED_MODULE_4__.createMemoryWithConsoleLogReporter; },
1428
- /* harmony export */ createStandardLog: function() { return /* reexport safe */ _standard_log_js__WEBPACK_IMPORTED_MODULE_5__.createStandardLog; },
1429
- /* harmony export */ createTimestampFormatter: function() { return /* reexport safe */ _formatter_js__WEBPACK_IMPORTED_MODULE_2__.createTimestampFormatter; },
1430
- /* harmony export */ formatLogLevel: function() { return /* reexport safe */ _formatter_js__WEBPACK_IMPORTED_MODULE_2__.formatLogLevel; },
1431
- /* harmony export */ getLogger: function() { return /* reexport safe */ _standard_log_js__WEBPACK_IMPORTED_MODULE_5__.getLogger; },
1432
- /* harmony export */ logLevels: function() { return /* reexport safe */ _log_levels_js__WEBPACK_IMPORTED_MODULE_3__.logLevels; },
1433
- /* harmony export */ plainLogFormatter: function() { return /* reexport safe */ _formatter_js__WEBPACK_IMPORTED_MODULE_2__.plainLogFormatter; },
1434
- /* harmony export */ suppressLogs: function() { return /* reexport safe */ _standard_log_js__WEBPACK_IMPORTED_MODULE_5__.suppressLogs; },
1435
- /* harmony export */ toConsoleMethod: function() { return /* reexport safe */ _console_js__WEBPACK_IMPORTED_MODULE_0__.toConsoleMethod; },
1436
- /* harmony export */ toLogLevel: function() { return /* reexport safe */ _log_levels_js__WEBPACK_IMPORTED_MODULE_3__.toLogLevel; },
1437
- /* harmony export */ toLogLevelName: function() { return /* reexport safe */ _log_levels_js__WEBPACK_IMPORTED_MODULE_3__.toLogLevelName; },
1438
- /* harmony export */ toMessageWithLevel: function() { return /* reexport safe */ _memory_js__WEBPACK_IMPORTED_MODULE_4__.toMessageWithLevel; }
1439
- /* harmony export */ });
1440
- /* harmony import */ var _console_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./console.js */ "./ts/console.ts");
1441
- /* harmony import */ var _errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./errors.js */ "./ts/errors.ts");
1442
- /* harmony import */ var _formatter_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./formatter.js */ "./ts/formatter.ts");
1443
- /* harmony import */ var _log_levels_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./log_levels.js */ "./ts/log_levels.ts");
1444
- /* harmony import */ var _memory_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./memory.js */ "./ts/memory.ts");
1445
- /* harmony import */ var _standard_log_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./standard_log.js */ "./ts/standard_log.ts");
1446
-
1447
-
1448
-
1449
-
1450
-
1451
-
901
+ function suppressLogs(block, ...logs) {
902
+ const origLevels = logs.map((l) => l.level);
903
+ logs.forEach((l) => l.level = logLevels.none);
904
+ const result = block();
905
+ logs.forEach((l, i) => l.level = origLevels[i]);
906
+ return result;
907
+ }
908
+ function getLogger(id, options) {
909
+ return getGlobalSL().getLogger(id, options);
910
+ }
911
+ function getGlobalSL() {
912
+ if (!ctx.gsl) ctx.gsl = createStandardLogClosure();
913
+ return ctx.gsl.standardLog;
914
+ }
915
+ function configGlobal(options) {
916
+ if (ctx.configured) ctx.gsl.standardLog.getLogger("standard-log").warn("configGlobal() is being called more than once. Please make sure this is expected. Application should use `createStandardLog()` most of the time.");
917
+ if (ctx.gsl) {
918
+ if (options.logLevel) ctx.gsl.store.logLevel = options.logLevel;
919
+ if (options.reporters) {
920
+ const reporters = ctx.gsl.store.reporters;
921
+ reporters.length = 0;
922
+ reporters.push(...options.reporters);
923
+ }
924
+ } else ctx.gsl = createStandardLogClosure(options);
925
+ ctx.configured = true;
926
+ }
927
+ //#endregion
928
+ export { DEFAULT_LOG_METHOD_NAMES, InvalidId, StandardLogError, configGlobal, consoleFormatter, createConsoleLogReporter, createMemoryLogReporter, createMemoryWithConsoleLogReporter, createStandardLog, createTimestampFormatter, formatLogLevel, getLogger, logLevels, plainLogFormatter, suppressLogs, toConsoleMethod, toLogLevel, toLogLevelName, toMessageWithLevel };
1452
929
 
1453
- }();
1454
- StandardLog = __webpack_exports__;
1455
- /******/ })()
1456
- ;
1457
930
  //# sourceMappingURL=standard-log.esm.js.map