standard-log 12.1.2 → 13.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +8 -8
  2. package/cjs/_virtual/_rolldown/runtime.js +23 -0
  3. package/cjs/console.d.ts +10 -7
  4. package/cjs/console.d.ts.map +1 -1
  5. package/cjs/console.js +53 -71
  6. package/cjs/console.js.map +1 -1
  7. package/cjs/errors.d.ts +9 -6
  8. package/cjs/errors.d.ts.map +1 -1
  9. package/cjs/errors.js +22 -45
  10. package/cjs/errors.js.map +1 -1
  11. package/cjs/formatter.d.ts +9 -6
  12. package/cjs/formatter.d.ts.map +1 -1
  13. package/cjs/formatter.js +41 -50
  14. package/cjs/formatter.js.map +1 -1
  15. package/cjs/index.d.ts +8 -9
  16. package/cjs/index.js +26 -28
  17. package/cjs/log_levels.d.ts +76 -73
  18. package/cjs/log_levels.d.ts.map +1 -1
  19. package/cjs/log_levels.js +104 -110
  20. package/cjs/log_levels.js.map +1 -1
  21. package/cjs/log_store.d.ts +20 -17
  22. package/cjs/log_store.d.ts.map +1 -1
  23. package/cjs/log_store.js +43 -39
  24. package/cjs/log_store.js.map +1 -1
  25. package/cjs/logger.d.ts +6 -3
  26. package/cjs/logger.d.ts.map +1 -1
  27. package/cjs/logger.js +66 -88
  28. package/cjs/logger.js.map +1 -1
  29. package/cjs/memory.d.ts +20 -17
  30. package/cjs/memory.d.ts.map +1 -1
  31. package/cjs/memory.js +54 -64
  32. package/cjs/memory.js.map +1 -1
  33. package/cjs/platform.browser.d.ts +7 -4
  34. package/cjs/platform.browser.d.ts.map +1 -1
  35. package/cjs/platform.browser.js +8 -6
  36. package/cjs/platform.browser.js.map +1 -1
  37. package/cjs/platform.d.ts +7 -4
  38. package/cjs/platform.d.ts.map +1 -1
  39. package/cjs/platform.js +9 -7
  40. package/cjs/platform.js.map +1 -1
  41. package/cjs/standard_log.ctx.d.ts +11 -8
  42. package/cjs/standard_log.ctx.d.ts.map +1 -1
  43. package/cjs/standard_log.ctx.js +6 -5
  44. package/cjs/standard_log.ctx.js.map +1 -1
  45. package/cjs/standard_log.d.ts +14 -12
  46. package/cjs/standard_log.d.ts.map +1 -1
  47. package/cjs/standard_log.js +83 -112
  48. package/cjs/standard_log.js.map +1 -1
  49. package/cjs/standard_log.testing.d.ts +16 -13
  50. package/cjs/standard_log.testing.d.ts.map +1 -1
  51. package/cjs/standard_log.testing.js +19 -35
  52. package/cjs/standard_log.testing.js.map +1 -1
  53. package/cjs/testing/index.d.ts +3 -3
  54. package/cjs/testing/index.js +3 -6
  55. package/cjs/types.d.ts +125 -124
  56. package/cjs/types.d.ts.map +1 -1
  57. package/cjs/types.js +0 -3
  58. package/dist/standard-log.esm.js +873 -1430
  59. package/dist/standard-log.esm.js.map +1 -1
  60. package/dist/standard-log.iife.js +952 -0
  61. package/dist/standard-log.iife.js.map +1 -0
  62. package/esm/console.d.ts +10 -7
  63. package/esm/console.d.ts.map +1 -1
  64. package/esm/console.js +54 -64
  65. package/esm/console.js.map +1 -1
  66. package/esm/errors.d.ts +9 -6
  67. package/esm/errors.d.ts.map +1 -1
  68. package/esm/errors.js +21 -21
  69. package/esm/errors.js.map +1 -1
  70. package/esm/formatter.d.ts +9 -6
  71. package/esm/formatter.d.ts.map +1 -1
  72. package/esm/formatter.js +38 -32
  73. package/esm/formatter.js.map +1 -1
  74. package/esm/index.d.ts +8 -9
  75. package/esm/index.js +7 -7
  76. package/esm/log_levels.d.ts +76 -73
  77. package/esm/log_levels.d.ts.map +1 -1
  78. package/esm/log_levels.js +102 -107
  79. package/esm/log_levels.js.map +1 -1
  80. package/esm/log_store.d.ts +20 -17
  81. package/esm/log_store.d.ts.map +1 -1
  82. package/esm/log_store.js +44 -37
  83. package/esm/log_store.js.map +1 -1
  84. package/esm/logger.d.ts +6 -3
  85. package/esm/logger.d.ts.map +1 -1
  86. package/esm/logger.js +66 -65
  87. package/esm/logger.js.map +1 -1
  88. package/esm/memory.d.ts +20 -17
  89. package/esm/memory.d.ts.map +1 -1
  90. package/esm/memory.js +55 -62
  91. package/esm/memory.js.map +1 -1
  92. package/esm/platform.browser.d.ts +7 -4
  93. package/esm/platform.browser.d.ts.map +1 -1
  94. package/esm/platform.browser.js +7 -3
  95. package/esm/platform.browser.js.map +1 -1
  96. package/esm/platform.d.ts +7 -4
  97. package/esm/platform.d.ts.map +1 -1
  98. package/esm/platform.js +8 -4
  99. package/esm/platform.js.map +1 -1
  100. package/esm/standard_log.ctx.d.ts +11 -8
  101. package/esm/standard_log.ctx.d.ts.map +1 -1
  102. package/esm/standard_log.ctx.js +6 -2
  103. package/esm/standard_log.ctx.js.map +1 -1
  104. package/esm/standard_log.d.ts +14 -12
  105. package/esm/standard_log.d.ts.map +1 -1
  106. package/esm/standard_log.js +83 -98
  107. package/esm/standard_log.js.map +1 -1
  108. package/esm/standard_log.testing.d.ts +16 -13
  109. package/esm/standard_log.testing.d.ts.map +1 -1
  110. package/esm/standard_log.testing.js +19 -20
  111. package/esm/standard_log.testing.js.map +1 -1
  112. package/esm/testing/index.d.ts +3 -3
  113. package/esm/testing/index.js +2 -2
  114. package/esm/types.d.ts +125 -124
  115. package/esm/types.d.ts.map +1 -1
  116. package/esm/types.js +0 -1
  117. package/package.json +21 -67
  118. package/ts/console.ts +7 -8
  119. package/ts/errors.ts +5 -2
  120. package/ts/formatter.ts +1 -2
  121. package/ts/index.ts +3 -3
  122. package/ts/log_levels.ts +2 -2
  123. package/ts/logger.ts +14 -7
  124. package/ts/memory.ts +3 -5
  125. package/ts/platform.ts +1 -1
  126. package/ts/standard_log.ts +2 -2
  127. package/ts/testing/index.ts +3 -3
  128. package/ts/types.ts +1 -1
  129. package/cjs/index.d.ts.map +0 -1
  130. package/cjs/index.js.map +0 -1
  131. package/cjs/testing/index.d.ts.map +0 -1
  132. package/cjs/testing/index.js.map +0 -1
  133. package/cjs/types.js.map +0 -1
  134. package/dist/standard-log.es5.js +0 -10184
  135. package/dist/standard-log.es5.js.gz +0 -0
  136. package/dist/standard-log.es5.js.map +0 -1
  137. package/dist/standard-log.es5.js.map.gz +0 -0
  138. package/dist/standard-log.esm.js.gz +0 -0
  139. package/dist/standard-log.esm.js.map.gz +0 -0
  140. package/esm/index.d.ts.map +0 -1
  141. package/esm/index.js.map +0 -1
  142. package/esm/testing/index.d.ts.map +0 -1
  143. package/esm/testing/index.js.map +0 -1
  144. package/esm/types.js.map +0 -1
package/cjs/logger.js CHANGED
@@ -1,98 +1,76 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createLogger = void 0;
13
- var log_levels_js_1 = require("./log_levels.js");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_log_levels = require("./log_levels.js");
3
+ //#region ts/logger.ts
14
4
  function createLogger(store, id, options) {
15
- var _a;
16
- id = sanitizeId(id);
17
- var writeTo = (_a = options === null || options === void 0 ? void 0 : options.writeTo) !== null && _a !== void 0 ? _a : (function () { return true; });
18
- var _b = typeof writeTo === 'string'
19
- ? [function (id) { return id === writeTo; }, store.reporters]
20
- : writeTo instanceof RegExp
21
- ? [function (id) { return writeTo.test(id); }, store.reporters]
22
- : typeof writeTo === 'function'
23
- ? [writeTo, store.reporters]
24
- : [function () { return true; }, [writeTo]], filter = _b[0], reporters = _b[1];
25
- function write(entry) {
26
- writeToReporters(reporters, entry, filter);
27
- }
28
- var logger = {
29
- level: options === null || options === void 0 ? void 0 : options.level,
30
- write: write
31
- };
32
- Object.defineProperties(logger, {
33
- id: { value: id, writable: false },
34
- count: {
35
- writable: false,
36
- value: (function (counter) {
37
- return function () {
38
- var args = [];
39
- for (var _i = 0; _i < arguments.length; _i++) {
40
- args[_i] = arguments[_i];
41
- }
42
- if (shouldLog(store, log_levels_js_1.logLevels.debug, logger.level))
43
- write({
44
- id: id,
45
- level: log_levels_js_1.logLevels.debug,
46
- args: __spreadArray([++counter], args, true),
47
- timestamp: new Date()
48
- });
49
- };
50
- })(0)
51
- },
52
- on: {
53
- writable: false,
54
- value: function (level, logFn) {
55
- var _a;
56
- var logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level) : level;
57
- if (shouldLog(store, logLevel, logger.level)) {
58
- var methodName = store.logLevelStore.getName(logLevel);
59
- var bindedMethod = logger[methodName].bind(logger);
60
- var result = logFn(bindedMethod, (_a = logger.level) !== null && _a !== void 0 ? _a : store.logLevel);
61
- if (result)
62
- bindedMethod(result);
63
- }
64
- }
65
- }
66
- });
67
- store.logLevelStore.getAllLevels().forEach(function addMethod(_a) {
68
- var name = _a.name, level = _a.level;
69
- Object.defineProperty(logger, name, {
70
- writable: false,
71
- value: function () {
72
- var args = [];
73
- for (var _i = 0; _i < arguments.length; _i++) {
74
- args[_i] = arguments[_i];
75
- }
76
- if (shouldLog(store, level, logger.level))
77
- write({ id: id, level: level, args: args, timestamp: new Date() });
78
- }
79
- });
80
- });
81
- return logger;
5
+ id = sanitizeId(id);
6
+ const writeTo = options?.writeTo ?? (() => true);
7
+ 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]];
8
+ function write(entry) {
9
+ writeToReporters(reporters, entry, filter);
10
+ }
11
+ const logger = {
12
+ level: options?.level,
13
+ write
14
+ };
15
+ Object.defineProperties(logger, {
16
+ id: {
17
+ value: id,
18
+ writable: false
19
+ },
20
+ count: {
21
+ writable: false,
22
+ value: ((counter) => (...args) => {
23
+ if (shouldLog(store, require_log_levels.logLevels.debug, logger.level)) write({
24
+ id,
25
+ level: require_log_levels.logLevels.debug,
26
+ args: [++counter, ...args],
27
+ timestamp: /* @__PURE__ */ new Date()
28
+ });
29
+ })(0)
30
+ },
31
+ on: {
32
+ writable: false,
33
+ value: (level, logFn) => {
34
+ const logLevel = typeof level === "string" ? store.logLevelStore.getLevel(level) : level;
35
+ if (shouldLog(store, logLevel, logger.level)) {
36
+ const methodName = store.logLevelStore.getName(logLevel);
37
+ const bindedMethod = logger[methodName].bind(logger);
38
+ const result = logFn(bindedMethod, logger.level ?? store.logLevel);
39
+ if (result) bindedMethod(result);
40
+ }
41
+ }
42
+ }
43
+ });
44
+ store.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {
45
+ Object.defineProperty(logger, name, {
46
+ writable: false,
47
+ value: (...args) => {
48
+ if (shouldLog(store, level, logger.level)) write({
49
+ id,
50
+ level,
51
+ args,
52
+ timestamp: /* @__PURE__ */ new Date()
53
+ });
54
+ }
55
+ });
56
+ });
57
+ return logger;
82
58
  }
83
- exports.createLogger = createLogger;
84
59
  function sanitizeId(id) {
85
- return id.replace(/[`~!#$%^&*()=+[\]{},|<>?]/g, '-');
60
+ return id.replace(/[`~!#$%^&*()=+[\]{},|<>?]/g, "-");
86
61
  }
87
62
  function writeToReporters(reporters, logEntry, filter) {
88
- reporters.filter(function (r) { return filter(r.id); }).forEach(function (r) { return r.write(logEntry); });
63
+ reporters.filter((r) => filter(r.id)).forEach((r) => r.write(logEntry));
89
64
  }
90
65
  /**
91
- * Determines should you log.
92
- * @param loggerLevel Log level of the logger.
93
- * It can be undefined which the global log level will be used.
94
- */
66
+ * Determines should you log.
67
+ * @param loggerLevel Log level of the logger.
68
+ * It can be undefined which the global log level will be used.
69
+ */
95
70
  function shouldLog(store, targetLevel, loggerLevel) {
96
- return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel);
71
+ return targetLevel <= (loggerLevel !== void 0 ? loggerLevel : store.logLevel);
97
72
  }
73
+ //#endregion
74
+ exports.createLogger = createLogger;
75
+
98
76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LogEntry, LogFunction, Logger, LoggerOptions, LogMethodNames, LogReporter } from './types.js'\nimport { LogLevel } from './types.js'\n\nexport function createLogger<N extends string = LogMethodNames>(\n\tstore: LogStore,\n\tid: string,\n\toptions?: LoggerOptions\n): Logger<N | LogMethodNames> {\n\tid = sanitizeId(id)\n\tconst writeTo = options?.writeTo ?? (() => true)\n\tconst [filter, reporters]: [(reporterId: string) => boolean, LogReporter[]] =\n\t\ttypeof writeTo === 'string'\n\t\t\t? [id => id === writeTo, store.reporters]\n\t\t\t: writeTo instanceof RegExp\n\t\t\t? [id => writeTo.test(id), store.reporters]\n\t\t\t: typeof writeTo === 'function'\n\t\t\t? [writeTo, store.reporters]\n\t\t\t: [() => true, [writeTo]]\n\n\tfunction write(entry: LogEntry) {\n\t\twriteToReporters(reporters, entry, filter)\n\t}\n\n\tconst logger = {\n\t\tlevel: options?.level,\n\t\twrite\n\t} as any\n\n\tObject.defineProperties(logger, {\n\t\tid: { value: id, writable: false },\n\t\tcount: {\n\t\t\twritable: false,\n\t\t\tvalue: (\n\t\t\t\tcounter =>\n\t\t\t\t(...args: any[]): void => {\n\t\t\t\t\tif (shouldLog(store, logLevels.debug, logger.level))\n\t\t\t\t\t\twrite({\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tlevel: logLevels.debug,\n\t\t\t\t\t\t\targs: [++counter, ...args],\n\t\t\t\t\t\t\ttimestamp: new Date()\n\t\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t)(0)\n\t\t},\n\t\ton: {\n\t\t\twritable: false,\n\t\t\tvalue: (level: number | N | LogMethodNames, logFn: LogFunction) => {\n\t\t\t\tconst logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level)! : level\n\t\t\t\tif (shouldLog(store, logLevel, logger.level)) {\n\t\t\t\t\tconst methodName = store.logLevelStore.getName(logLevel)\n\t\t\t\t\tconst bindedMethod = logger[methodName].bind(logger)\n\t\t\t\t\tconst result = logFn(bindedMethod, logger.level ?? store.logLevel)\n\t\t\t\t\tif (result) bindedMethod(result)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\tstore.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {\n\t\tObject.defineProperty(logger, name, {\n\t\t\twritable: false,\n\t\t\tvalue: (...args: any[]) => {\n\t\t\t\tif (shouldLog(store, level, logger.level)) write({ id, level, args, timestamp: new Date() })\n\t\t\t}\n\t\t})\n\t})\n\treturn logger\n}\n\nfunction sanitizeId(id: string) {\n\treturn id.replace(/[`~!#$%^&*()=+[\\]{},|<>?]/g, '-')\n}\n\nfunction writeToReporters(\n\treporters: LogReporter[],\n\tlogEntry: LogEntry,\n\tfilter: (reporterId: string) => boolean\n) {\n\treporters.filter(r => filter(r.id)).forEach(r => r.write(logEntry!))\n}\n\n/**\n * Determines should you log.\n * @param loggerLevel Log level of the logger.\n * It can be undefined which the global log level will be used.\n */\nfunction shouldLog(store: LogStore, targetLevel: LogLevel, loggerLevel: LogLevel | undefined) {\n\treturn targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel)\n}\n"]}
1
+ {"version":3,"file":"logger.js","names":["logLevels"],"sources":["../ts/logger.ts"],"sourcesContent":["import { logLevels } from './log_levels.js'\nimport type { LogStore } from './log_store.js'\nimport type {\n\tLogEntry,\n\tLogFunction,\n\tLogger,\n\tLoggerOptions,\n\tLogLevel,\n\tLogMethodNames,\n\tLogReporter\n} from './types.js'\n\nexport function createLogger<N extends string = LogMethodNames>(\n\tstore: LogStore,\n\tid: string,\n\toptions?: LoggerOptions\n): Logger<N | LogMethodNames> {\n\tid = sanitizeId(id)\n\tconst writeTo = options?.writeTo ?? (() => true)\n\tconst [filter, reporters]: [(reporterId: string) => boolean, LogReporter[]] =\n\t\ttypeof writeTo === 'string'\n\t\t\t? [id => id === writeTo, store.reporters]\n\t\t\t: writeTo instanceof RegExp\n\t\t\t\t? [id => writeTo.test(id), store.reporters]\n\t\t\t\t: typeof writeTo === 'function'\n\t\t\t\t\t? [writeTo, store.reporters]\n\t\t\t\t\t: [() => true, [writeTo]]\n\n\tfunction write(entry: LogEntry) {\n\t\twriteToReporters(reporters, entry, filter)\n\t}\n\n\tconst logger = {\n\t\tlevel: options?.level,\n\t\twrite\n\t} as any\n\n\tObject.defineProperties(logger, {\n\t\tid: { value: id, writable: false },\n\t\tcount: {\n\t\t\twritable: false,\n\t\t\tvalue: (\n\t\t\t\tcounter =>\n\t\t\t\t(...args: any[]): void => {\n\t\t\t\t\tif (shouldLog(store, logLevels.debug, logger.level))\n\t\t\t\t\t\twrite({\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tlevel: logLevels.debug,\n\t\t\t\t\t\t\targs: [++counter, ...args],\n\t\t\t\t\t\t\ttimestamp: new Date()\n\t\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t)(0)\n\t\t},\n\t\ton: {\n\t\t\twritable: false,\n\t\t\tvalue: (level: number | N | LogMethodNames, logFn: LogFunction) => {\n\t\t\t\tconst logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level)! : level\n\t\t\t\tif (shouldLog(store, logLevel, logger.level)) {\n\t\t\t\t\tconst methodName = store.logLevelStore.getName(logLevel)\n\t\t\t\t\tconst bindedMethod = logger[methodName].bind(logger)\n\t\t\t\t\tconst result = logFn(bindedMethod, logger.level ?? store.logLevel)\n\t\t\t\t\tif (result) bindedMethod(result)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t})\n\tstore.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {\n\t\tObject.defineProperty(logger, name, {\n\t\t\twritable: false,\n\t\t\tvalue: (...args: any[]) => {\n\t\t\t\tif (shouldLog(store, level, logger.level)) write({ id, level, args, timestamp: new Date() })\n\t\t\t}\n\t\t})\n\t})\n\treturn logger\n}\n\nfunction sanitizeId(id: string) {\n\treturn id.replace(/[`~!#$%^&*()=+[\\]{},|<>?]/g, '-')\n}\n\nfunction writeToReporters(\n\treporters: LogReporter[],\n\tlogEntry: LogEntry,\n\tfilter: (reporterId: string) => boolean\n) {\n\treporters.filter(r => filter(r.id)).forEach(r => r.write(logEntry!))\n}\n\n/**\n * Determines should you log.\n * @param loggerLevel Log level of the logger.\n * It can be undefined which the global log level will be used.\n */\nfunction shouldLog(store: LogStore, targetLevel: LogLevel, loggerLevel: LogLevel | undefined) {\n\treturn targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel)\n}\n"],"mappings":";;;AAYA,SAAgB,aACf,OACA,IACA,SAC6B;CAC7B,KAAK,WAAW,EAAE;CAClB,MAAM,UAAU,SAAS,kBAAkB;CAC3C,MAAM,CAAC,QAAQ,aACd,OAAO,YAAY,WAChB,EAAC,OAAM,OAAO,SAAS,MAAM,SAAS,IACtC,mBAAmB,SAClB,EAAC,OAAM,QAAQ,KAAK,EAAE,GAAG,MAAM,SAAS,IACxC,OAAO,YAAY,aAClB,CAAC,SAAS,MAAM,SAAS,IACzB,OAAO,MAAM,CAAC,OAAO,CAAC;CAE5B,SAAS,MAAM,OAAiB;EAC/B,iBAAiB,WAAW,OAAO,MAAM;CAC1C;CAEA,MAAM,SAAS;EACd,OAAO,SAAS;EAChB;CACD;CAEA,OAAO,iBAAiB,QAAQ;EAC/B,IAAI;GAAE,OAAO;GAAI,UAAU;EAAM;EACjC,OAAO;GACN,UAAU;GACV,SACC,aACC,GAAG,SAAsB;IACzB,IAAI,UAAU,OAAOA,mBAAAA,UAAU,OAAO,OAAO,KAAK,GACjD,MAAM;KACL;KACA,OAAOA,mBAAAA,UAAU;KACjB,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI;KACzB,2BAAW,IAAI,KAAK;IACrB,CAAC;GACH,EAAA,CACC,CAAC;EACJ;EACA,IAAI;GACH,UAAU;GACV,QAAQ,OAAoC,UAAuB;IAClE,MAAM,WAAW,OAAO,UAAU,WAAW,MAAM,cAAc,SAAS,KAAK,IAAK;IACpF,IAAI,UAAU,OAAO,UAAU,OAAO,KAAK,GAAG;KAC7C,MAAM,aAAa,MAAM,cAAc,QAAQ,QAAQ;KACvD,MAAM,eAAe,OAAO,WAAW,CAAC,KAAK,MAAM;KACnD,MAAM,SAAS,MAAM,cAAc,OAAO,SAAS,MAAM,QAAQ;KACjE,IAAI,QAAQ,aAAa,MAAM;IAChC;GACD;EACD;CACD,CAAC;CACD,MAAM,cAAc,aAAa,CAAC,CAAC,QAAQ,SAAS,UAAU,EAAE,MAAM,SAAS;EAC9E,OAAO,eAAe,QAAQ,MAAM;GACnC,UAAU;GACV,QAAQ,GAAG,SAAgB;IAC1B,IAAI,UAAU,OAAO,OAAO,OAAO,KAAK,GAAG,MAAM;KAAE;KAAI;KAAO;KAAM,2BAAW,IAAI,KAAK;IAAE,CAAC;GAC5F;EACD,CAAC;CACF,CAAC;CACD,OAAO;AACR;AAEA,SAAS,WAAW,IAAY;CAC/B,OAAO,GAAG,QAAQ,8BAA8B,GAAG;AACpD;AAEA,SAAS,iBACR,WACA,UACA,QACC;CACD,UAAU,QAAO,MAAK,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,SAAQ,MAAK,EAAE,MAAM,QAAS,CAAC;AACpE;;;;;;AAOA,SAAS,UAAU,OAAiB,aAAuB,aAAmC;CAC7F,OAAO,gBAAgB,gBAAgB,KAAA,IAAY,cAAc,MAAM;AACxE"}
package/cjs/memory.d.ts CHANGED
@@ -1,19 +1,22 @@
1
- import type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js';
2
- export type MemoryLogReporter = LogReporter<LogEntry> & {
3
- logs: LogEntry[];
4
- /**
5
- * Gets a simple log message for testing.
6
- * The message only contains arguments for each log entry.
7
- */
8
- getLogMessage(): string;
9
- getLogMessages(): string[];
10
- getLogMessageWithLevel(): string;
11
- getLogMessagesWithLevel(): string[];
12
- getLogMessagesWithIdAndLevel(): string[];
13
- emit(): void;
1
+ import { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from "./types.js";
2
+ //#region ts/memory.d.ts
3
+ type MemoryLogReporter = LogReporter<LogEntry> & {
4
+ logs: LogEntry[];
5
+ /**
6
+ * Gets a simple log message for testing.
7
+ * The message only contains arguments for each log entry.
8
+ */
9
+ getLogMessage(): string;
10
+ getLogMessages(): string[];
11
+ getLogMessageWithLevel(): string;
12
+ getLogMessagesWithLevel(): string[];
13
+ getLogMessagesWithIdAndLevel(): string[];
14
+ emit(): void;
14
15
  };
15
- export type MemoryLogFormatter = LogFormatter<LogEntry>;
16
- export declare function toMessageWithLevel(logs: LogEntry[]): string;
17
- export declare function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
18
- export declare function createMemoryWithConsoleLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
16
+ type MemoryLogFormatter = LogFormatter<LogEntry>;
17
+ declare function toMessageWithLevel(logs: LogEntry[]): string;
18
+ declare function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
19
+ declare function createMemoryWithConsoleLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
20
+ //#endregion
21
+ export { MemoryLogFormatter, MemoryLogReporter, createMemoryLogReporter, createMemoryWithConsoleLogReporter, toMessageWithLevel };
19
22
  //# sourceMappingURL=memory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../ts/memory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGzF,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG;IACvD,IAAI,EAAE,QAAQ,EAAE,CAAA;IAChB;;;OAGG;IACH,aAAa,IAAI,MAAM,CAAA;IACvB,cAAc,IAAI,MAAM,EAAE,CAAA;IAC1B,sBAAsB,IAAI,MAAM,CAAA;IAChC,uBAAuB,IAAI,MAAM,EAAE,CAAA;IACnC,4BAA4B,IAAI,MAAM,EAAE,CAAA;IACxC,IAAI,IAAI,IAAI,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AAEvD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAWlD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAEjG;AA+CD,wBAAgB,kCAAkC,CACjD,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GACpC,iBAAiB,CAMnB"}
1
+ {"version":3,"file":"memory.d.ts","names":[],"sources":["../ts/memory.ts"],"mappings":";;KAMY,oBAAoB,YAAY;EAC3C,MAAM;;;;;EAKN;EACA;EACA;EACA;EACA;EACA;;KAGW,qBAAqB,aAAa;iBAE9B,mBAAmB,MAAM;iBAazB,wBAAwB,UAAU,mBAAmB,YAAY;iBA+CjE,mCACf,UAAU,mBAAmB,YAC3B"}
package/cjs/memory.js CHANGED
@@ -1,74 +1,64 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMemoryWithConsoleLogReporter = exports.createMemoryLogReporter = exports.toMessageWithLevel = void 0;
4
- var type_plus_1 = require("type-plus");
5
- var platform_js_1 = require("./platform.js");
6
- var formatter_js_1 = require("./formatter.js");
7
- var console_js_1 = require("./console.js");
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_formatter = require("./formatter.js");
3
+ const require_platform = require("./platform.js");
4
+ const require_console = require("./console.js");
5
+ let type_plus = require("type-plus");
6
+ //#region ts/memory.ts
8
7
  function toMessageWithLevel(logs) {
9
- return (logs
10
- .map(platform_js_1.toInspectLogEntry)
11
- .map(function (log) { return "".concat((0, formatter_js_1.formatLogLevel)(log.level), " ").concat(log.args.join(' ')); })
12
- .join('\n')
13
- // if it has more than this log,
14
- // we assume it is running under tests,
15
- // and remove this log to simplify testing.
16
- .replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, ''));
8
+ return logs.map(require_platform.toInspectLogEntry).map((log) => `${require_formatter.formatLogLevel(log.level)} ${log.args.join(" ")}`).join("\n").replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, "");
17
9
  }
18
- exports.toMessageWithLevel = toMessageWithLevel;
19
10
  function createMemoryLogReporter(options) {
20
- return Object.freeze(buildMemoryReporter((0, type_plus_1.unpartial)({ id: 'memory' }, options)));
11
+ return Object.freeze(buildMemoryReporter((0, type_plus.unpartial)({ id: "memory" }, options)));
21
12
  }
22
- exports.createMemoryLogReporter = createMemoryLogReporter;
23
13
  function buildMemoryReporter(options) {
24
- var _a = (0, type_plus_1.required)({ id: 'memory', formatter: function (e) { return e; } }, options), id = _a.id, formatter = _a.formatter, filter = _a.filter;
25
- var logs = [];
26
- return {
27
- id: id,
28
- get formatter() {
29
- return formatter;
30
- },
31
- get filter() {
32
- return filter;
33
- },
34
- logs: logs,
35
- write: function (entry) {
36
- if (filter && !filter(entry))
37
- return;
38
- logs.push(formatter(entry));
39
- },
40
- getLogMessage: function () {
41
- return this.getLogMessages().join('\n');
42
- },
43
- getLogMessages: function () {
44
- return logs.map(platform_js_1.toInspectLogEntry).map(function (log) { return log.args.join(' '); });
45
- },
46
- getLogMessagesWithLevel: function () {
47
- return logs
48
- .map(platform_js_1.toInspectLogEntry)
49
- .map(function (log) { return "".concat((0, formatter_js_1.formatLogLevel)(log.level), " ").concat(log.args.join(' ')); });
50
- },
51
- getLogMessagesWithIdAndLevel: function () {
52
- return logs
53
- .map(platform_js_1.toInspectLogEntry)
54
- .map(function (log) { return "".concat(log.id, " ").concat((0, formatter_js_1.formatLogLevel)(log.level), " ").concat(log.args.join(' ')); });
55
- },
56
- getLogMessageWithLevel: function () {
57
- return toMessageWithLevel(logs);
58
- },
59
- /**
60
- * emit the saved log to console for easy debugging
61
- */
62
- emit: function () {
63
- var reporter = (0, console_js_1.createConsoleLogReporter)();
64
- logs.forEach(function (l) { return reporter.write(l); });
65
- }
66
- };
14
+ const { id, formatter, filter } = (0, type_plus.required)({
15
+ id: "memory",
16
+ formatter: (e) => e
17
+ }, options);
18
+ const logs = [];
19
+ return {
20
+ id,
21
+ get formatter() {
22
+ return formatter;
23
+ },
24
+ get filter() {
25
+ return filter;
26
+ },
27
+ logs,
28
+ write(entry) {
29
+ if (filter && !filter(entry)) return;
30
+ logs.push(formatter(entry));
31
+ },
32
+ getLogMessage() {
33
+ return this.getLogMessages().join("\n");
34
+ },
35
+ getLogMessages() {
36
+ return logs.map(require_platform.toInspectLogEntry).map((log) => log.args.join(" "));
37
+ },
38
+ getLogMessagesWithLevel() {
39
+ return logs.map(require_platform.toInspectLogEntry).map((log) => `${require_formatter.formatLogLevel(log.level)} ${log.args.join(" ")}`);
40
+ },
41
+ getLogMessagesWithIdAndLevel() {
42
+ return logs.map(require_platform.toInspectLogEntry).map((log) => `${log.id} ${require_formatter.formatLogLevel(log.level)} ${log.args.join(" ")}`);
43
+ },
44
+ getLogMessageWithLevel() {
45
+ return toMessageWithLevel(logs);
46
+ },
47
+ /**
48
+ * emit the saved log to console for easy debugging
49
+ */
50
+ emit() {
51
+ const reporter = require_console.createConsoleLogReporter();
52
+ logs.forEach((l) => reporter.write(l));
53
+ }
54
+ };
67
55
  }
68
56
  function createMemoryWithConsoleLogReporter(options) {
69
- return Object.freeze(Object.assign(buildMemoryReporter((0, type_plus_1.unpartial)({ id: 'memory-with-console' }, options)), {
70
- isConsoleReporter: true
71
- }));
57
+ return Object.freeze(Object.assign(buildMemoryReporter((0, type_plus.unpartial)({ id: "memory-with-console" }, options)), { isConsoleReporter: true }));
72
58
  }
59
+ //#endregion
60
+ exports.createMemoryLogReporter = createMemoryLogReporter;
73
61
  exports.createMemoryWithConsoleLogReporter = createMemoryWithConsoleLogReporter;
62
+ exports.toMessageWithLevel = toMessageWithLevel;
63
+
74
64
  //# sourceMappingURL=memory.js.map
package/cjs/memory.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"memory.js","sourceRoot":"","sources":["../ts/memory.ts"],"names":[],"mappings":";;;A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AM,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE;QACrF,iBAAiB,EAAE,IAAI;KACvB,CAAC,CACF,CAAA;AACF,CAAC;AARD,gFAQC","sourcesContent":["import { required, unpartial } from 'type-plus'\nimport { toInspectLogEntry } from './platform.js'\nimport { formatLogLevel } from './formatter.js'\nimport type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\nimport { createConsoleLogReporter } from './console.js'\n\nexport type MemoryLogReporter = LogReporter<LogEntry> & {\n\tlogs: LogEntry[]\n\t/**\n\t * Gets a simple log message for testing.\n\t * The message only contains arguments for each log entry.\n\t */\n\tgetLogMessage(): string\n\tgetLogMessages(): string[]\n\tgetLogMessageWithLevel(): string\n\tgetLogMessagesWithLevel(): string[]\n\tgetLogMessagesWithIdAndLevel(): string[]\n\temit(): void\n}\n\nexport type MemoryLogFormatter = LogFormatter<LogEntry>\n\nexport function toMessageWithLevel(logs: LogEntry[]) {\n\treturn (\n\t\tlogs\n\t\t\t.map(toInspectLogEntry)\n\t\t\t.map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t\t.join('\\n')\n\t\t\t// if it has more than this log,\n\t\t\t// we assume it is running under tests,\n\t\t\t// and remove this log to simplify testing.\n\t\t\t.replace(/^\\(WARN\\) already configured for test, ignoring config\\(\\) call\\n/, '')\n\t)\n}\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n\treturn Object.freeze(buildMemoryReporter(unpartial({ id: 'memory' }, options)))\n}\n\nfunction buildMemoryReporter(options?: LogReporterOptions<LogEntry>) {\n\tconst { id, formatter, filter } = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n\tconst logs: LogEntry[] = []\n\treturn {\n\t\tid,\n\t\tget formatter() {\n\t\t\treturn formatter\n\t\t},\n\t\tget filter() {\n\t\t\treturn filter\n\t\t},\n\t\tlogs,\n\t\twrite(entry: LogEntry) {\n\t\t\tif (filter && !filter(entry)) return\n\t\t\tlogs.push(formatter(entry))\n\t\t},\n\t\tgetLogMessage() {\n\t\t\treturn this.getLogMessages().join('\\n')\n\t\t},\n\t\tgetLogMessages() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => log.args.join(' '))\n\t\t},\n\t\tgetLogMessagesWithLevel() {\n\t\t\treturn logs\n\t\t\t\t.map(toInspectLogEntry)\n\t\t\t\t.map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessagesWithIdAndLevel() {\n\t\t\treturn logs\n\t\t\t\t.map(toInspectLogEntry)\n\t\t\t\t.map(log => `${log.id} ${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessageWithLevel() {\n\t\t\treturn toMessageWithLevel(logs)\n\t\t},\n\t\t/**\n\t\t * emit the saved log to console for easy debugging\n\t\t */\n\t\temit() {\n\t\t\tconst reporter = createConsoleLogReporter()\n\t\t\tlogs.forEach(l => reporter.write(l))\n\t\t}\n\t}\n}\n\nexport function createMemoryWithConsoleLogReporter(\n\toptions?: LogReporterOptions<LogEntry>\n): MemoryLogReporter {\n\treturn Object.freeze(\n\t\tObject.assign(buildMemoryReporter(unpartial({ id: 'memory-with-console' }, options)), {\n\t\t\tisConsoleReporter: true\n\t\t})\n\t)\n}\n"]}
1
+ {"version":3,"file":"memory.js","names":["toInspectLogEntry","formatLogLevel","unpartial","required","createConsoleLogReporter"],"sources":["../ts/memory.ts"],"sourcesContent":["import { required, unpartial } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { formatLogLevel } from './formatter.js'\nimport { toInspectLogEntry } from './platform.js'\nimport type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport type MemoryLogReporter = LogReporter<LogEntry> & {\n\tlogs: LogEntry[]\n\t/**\n\t * Gets a simple log message for testing.\n\t * The message only contains arguments for each log entry.\n\t */\n\tgetLogMessage(): string\n\tgetLogMessages(): string[]\n\tgetLogMessageWithLevel(): string\n\tgetLogMessagesWithLevel(): string[]\n\tgetLogMessagesWithIdAndLevel(): string[]\n\temit(): void\n}\n\nexport type MemoryLogFormatter = LogFormatter<LogEntry>\n\nexport function toMessageWithLevel(logs: LogEntry[]) {\n\treturn (\n\t\tlogs\n\t\t\t.map(toInspectLogEntry)\n\t\t\t.map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t\t.join('\\n')\n\t\t\t// if it has more than this log,\n\t\t\t// we assume it is running under tests,\n\t\t\t// and remove this log to simplify testing.\n\t\t\t.replace(/^\\(WARN\\) already configured for test, ignoring config\\(\\) call\\n/, '')\n\t)\n}\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n\treturn Object.freeze(buildMemoryReporter(unpartial({ id: 'memory' }, options)))\n}\n\nfunction buildMemoryReporter(options?: LogReporterOptions<LogEntry>) {\n\tconst { id, formatter, filter } = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n\tconst logs: LogEntry[] = []\n\treturn {\n\t\tid,\n\t\tget formatter() {\n\t\t\treturn formatter\n\t\t},\n\t\tget filter() {\n\t\t\treturn filter\n\t\t},\n\t\tlogs,\n\t\twrite(entry: LogEntry) {\n\t\t\tif (filter && !filter(entry)) return\n\t\t\tlogs.push(formatter(entry))\n\t\t},\n\t\tgetLogMessage() {\n\t\t\treturn this.getLogMessages().join('\\n')\n\t\t},\n\t\tgetLogMessages() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => log.args.join(' '))\n\t\t},\n\t\tgetLogMessagesWithLevel() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessagesWithIdAndLevel() {\n\t\t\treturn logs\n\t\t\t\t.map(toInspectLogEntry)\n\t\t\t\t.map(log => `${log.id} ${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessageWithLevel() {\n\t\t\treturn toMessageWithLevel(logs)\n\t\t},\n\t\t/**\n\t\t * emit the saved log to console for easy debugging\n\t\t */\n\t\temit() {\n\t\t\tconst reporter = createConsoleLogReporter()\n\t\t\tlogs.forEach(l => reporter.write(l))\n\t\t}\n\t}\n}\n\nexport function createMemoryWithConsoleLogReporter(\n\toptions?: LogReporterOptions<LogEntry>\n): MemoryLogReporter {\n\treturn Object.freeze(\n\t\tObject.assign(buildMemoryReporter(unpartial({ id: 'memory-with-console' }, options)), {\n\t\t\tisConsoleReporter: true\n\t\t})\n\t)\n}\n"],"mappings":";;;;;;AAsBA,SAAgB,mBAAmB,MAAkB;CACpD,OACC,KACE,IAAIA,iBAAAA,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAGC,kBAAAA,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG,CAAC,CAChE,KAAK,IAAI,CAAC,CAIV,QAAQ,qEAAqE,EAAE;AAEnF;AAEA,SAAgB,wBAAwB,SAA2D;CAClG,OAAO,OAAO,OAAO,qBAAA,GAAoBC,UAAAA,UAAAA,CAAU,EAAE,IAAI,SAAS,GAAG,OAAO,CAAC,CAAC;AAC/E;AAEA,SAAS,oBAAoB,SAAwC;CACpE,MAAM,EAAE,IAAI,WAAW,YAAA,GAAWC,UAAAA,SAAAA,CAAS;EAAE,IAAI;EAAU,YAAY,MAAgB;CAAE,GAAG,OAAO;CACnG,MAAM,OAAmB,CAAC;CAC1B,OAAO;EACN;EACA,IAAI,YAAY;GACf,OAAO;EACR;EACA,IAAI,SAAS;GACZ,OAAO;EACR;EACA;EACA,MAAM,OAAiB;GACtB,IAAI,UAAU,CAAC,OAAO,KAAK,GAAG;GAC9B,KAAK,KAAK,UAAU,KAAK,CAAC;EAC3B;EACA,gBAAgB;GACf,OAAO,KAAK,eAAe,CAAC,CAAC,KAAK,IAAI;EACvC;EACA,iBAAiB;GAChB,OAAO,KAAK,IAAIH,iBAAAA,iBAAiB,CAAC,CAAC,KAAI,QAAO,IAAI,KAAK,KAAK,GAAG,CAAC;EACjE;EACA,0BAA0B;GACzB,OAAO,KAAK,IAAIA,iBAAAA,iBAAiB,CAAC,CAAC,KAAI,QAAO,GAAGC,kBAAAA,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EACnG;EACA,+BAA+B;GAC9B,OAAO,KACL,IAAID,iBAAAA,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAG,IAAI,GAAG,GAAGC,kBAAAA,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EAC5E;EACA,yBAAyB;GACxB,OAAO,mBAAmB,IAAI;EAC/B;;;;EAIA,OAAO;GACN,MAAM,WAAWG,gBAAAA,yBAAyB;GAC1C,KAAK,SAAQ,MAAK,SAAS,MAAM,CAAC,CAAC;EACpC;CACD;AACD;AAEA,SAAgB,mCACf,SACoB;CACpB,OAAO,OAAO,OACb,OAAO,OAAO,qBAAA,GAAoBF,UAAAA,UAAAA,CAAU,EAAE,IAAI,sBAAsB,GAAG,OAAO,CAAC,GAAG,EACrF,mBAAmB,KACpB,CAAC,CACF;AACD"}
@@ -1,6 +1,9 @@
1
- import type { ConsoleLike, LogEntry } from './types.js';
2
- export declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
3
- export declare const polyfill: {
4
- console?: ConsoleLike;
1
+ import { ConsoleLike, LogEntry } from "./types.js";
2
+ //#region ts/platform.browser.d.ts
3
+ declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
4
+ declare const polyfill: {
5
+ console?: ConsoleLike;
5
6
  };
7
+ //#endregion
8
+ export { polyfill, toInspectLogEntry };
6
9
  //# sourceMappingURL=platform.browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.browser.d.ts","sourceRoot":"","sources":["../ts/platform.browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,MAAO,QAAQ,aAAM,CAAA;AAEnD,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAa,CAAA"}
1
+ {"version":3,"file":"platform.browser.d.ts","names":[],"sources":["../ts/platform.browser.ts"],"mappings":";;cAGa,oBAAiB,GAAO,aAAQ;cAEhC;EAAY,UAAU"}
@@ -1,8 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.polyfill = exports.toInspectLogEntry = void 0;
4
- var type_plus_1 = require("type-plus");
5
- var toInspectLogEntry = function (e) { return e; };
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let type_plus = require("type-plus");
3
+ //#region ts/platform.browser.ts
4
+ const toInspectLogEntry = (e) => e;
5
+ const polyfill = (0, type_plus.record)();
6
+ //#endregion
7
+ exports.polyfill = polyfill;
6
8
  exports.toInspectLogEntry = toInspectLogEntry;
7
- exports.polyfill = (0, type_plus_1.record)();
9
+
8
10
  //# sourceMappingURL=platform.browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.browser.js","sourceRoot":"","sources":["../ts/platform.browser.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAG3B,IAAM,iBAAiB,GAAG,UAAC,CAAW,IAAK,OAAA,CAAC,EAAD,CAAC,CAAA;AAAtC,QAAA,iBAAiB,qBAAqB;AAEtC,QAAA,QAAQ,GAA8B,IAAA,kBAAM,GAAE,CAAA","sourcesContent":["import { record } from 'type-plus'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => e\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"]}
1
+ {"version":3,"file":"platform.browser.js","names":["record"],"sources":["../ts/platform.browser.ts"],"sourcesContent":["import { record } from 'type-plus'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => e\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"],"mappings":";;;AAGA,MAAa,qBAAqB,MAAgB;AAElD,MAAa,YAAA,GAAsCA,UAAAA,OAAAA,CAAO"}
package/cjs/platform.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import type { ConsoleLike, LogEntry } from './types.js';
2
- export declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
3
- export declare const polyfill: {
4
- console?: ConsoleLike;
1
+ import { ConsoleLike, LogEntry } from "./types.js";
2
+ //#region ts/platform.d.ts
3
+ declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
4
+ declare const polyfill: {
5
+ console?: ConsoleLike;
5
6
  };
7
+ //#endregion
8
+ export { polyfill, toInspectLogEntry };
6
9
  //# sourceMappingURL=platform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,MAAO,QAAQ,aAE5C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAa,CAAA"}
1
+ {"version":3,"file":"platform.d.ts","names":[],"sources":["../ts/platform.ts"],"mappings":";;cAIa,oBAAiB,GAAO,aAAQ;cAIhC;EAAY,UAAU"}
package/cjs/platform.js CHANGED
@@ -1,9 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.polyfill = exports.toInspectLogEntry = void 0;
4
- var type_plus_1 = require("type-plus");
5
- var util_1 = require("util");
6
- var toInspectLogEntry = function (e) { return ((e.args = e.args.map(function (value) { return (typeof value === 'object' && value !== null ? (0, util_1.inspect)(value) : value); })), e); };
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let type_plus = require("type-plus");
3
+ let node_util = require("node:util");
4
+ //#region ts/platform.ts
5
+ const toInspectLogEntry = (e) => (e.args = e.args.map((value) => typeof value === "object" && value !== null ? (0, node_util.inspect)(value) : value), e);
6
+ const polyfill = (0, type_plus.record)();
7
+ //#endregion
8
+ exports.polyfill = polyfill;
7
9
  exports.toInspectLogEntry = toInspectLogEntry;
8
- exports.polyfill = (0, type_plus_1.record)();
10
+
9
11
  //# sourceMappingURL=platform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.js","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAClC,6BAA8B;AAGvB,IAAM,iBAAiB,GAAG,UAAC,CAAW,IAAK,OAAA,CACjD,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAtE,CAAsE,CAAC,CAAC,EAAE,CAAC,CACzG,EAFiD,CAEjD,CAAA;AAFY,QAAA,iBAAiB,qBAE7B;AAEY,QAAA,QAAQ,GAA8B,IAAA,kBAAM,GAAE,CAAA","sourcesContent":["import { record } from 'type-plus'\nimport { inspect } from 'util'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => (\n\t(e.args = e.args.map(value => (typeof value === 'object' && value !== null ? inspect(value) : value))), e\n)\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"]}
1
+ {"version":3,"file":"platform.js","names":["inspect","record"],"sources":["../ts/platform.ts"],"sourcesContent":["import { inspect } from 'node:util'\nimport { record } from 'type-plus'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => (\n\t(e.args = e.args.map(value => (typeof value === 'object' && value !== null ? inspect(value) : value))), e\n)\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"],"mappings":";;;;AAIA,MAAa,qBAAqB,OAChC,EAAE,OAAO,EAAE,KAAK,KAAI,UAAU,OAAO,UAAU,YAAY,UAAU,QAAA,GAAOA,UAAAA,QAAAA,CAAQ,KAAK,IAAI,KAAM,GAAI;AAGzG,MAAa,YAAA,GAAsCC,UAAAA,OAAAA,CAAO"}
@@ -1,10 +1,13 @@
1
- import type { LogStore } from './log_store.js';
2
- import type { LogMethodNames, StandardLogInstance } from './types.js';
3
- export declare const ctx: {
4
- configured?: boolean;
5
- gsl?: {
6
- store: LogStore;
7
- standardLog: StandardLogInstance<LogMethodNames>;
8
- };
1
+ import { LogMethodNames, StandardLogInstance } from "./types.js";
2
+ import { LogStore } from "./log_store.js";
3
+ //#region ts/standard_log.ctx.d.ts
4
+ declare const ctx: {
5
+ configured?: boolean;
6
+ gsl?: {
7
+ store: LogStore;
8
+ standardLog: StandardLogInstance<LogMethodNames>;
9
+ };
9
10
  };
11
+ //#endregion
12
+ export { ctx };
10
13
  //# sourceMappingURL=standard_log.ctx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard_log.ctx.d.ts","sourceRoot":"","sources":["../ts/standard_log.ctx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErE,eAAO,MAAM,GAAG,EAAE;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAC;QAAC,WAAW,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAA;KAAE,CAAA;CAChE,CAAA"}
1
+ {"version":3,"file":"standard_log.ctx.d.ts","names":[],"sources":["../ts/standard_log.ctx.ts"],"mappings":";;;cAIa;EACZ;EACA;IAAQ,OAAO;IAAU,aAAa,oBAAoB"}
@@ -1,6 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ctx = void 0;
4
- var type_plus_1 = require("type-plus");
5
- exports.ctx = (0, type_plus_1.record)();
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region ts/standard_log.ctx.ts
3
+ const ctx = (0, require("type-plus").record)();
4
+ //#endregion
5
+ exports.ctx = ctx;
6
+
6
7
  //# sourceMappingURL=standard_log.ctx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard_log.ctx.js","sourceRoot":"","sources":["../ts/standard_log.ctx.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAIrB,QAAA,GAAG,GAGZ,IAAA,kBAAM,GAAE,CAAA","sourcesContent":["import { record } from 'type-plus'\nimport type { LogStore } from './log_store.js'\nimport type { LogMethodNames, StandardLogInstance } from './types.js'\n\nexport const ctx: {\n\tconfigured?: boolean\n\tgsl?: { store: LogStore; standardLog: StandardLogInstance<LogMethodNames> }\n} = record()\n"]}
1
+ {"version":3,"file":"standard_log.ctx.js","names":["record"],"sources":["../ts/standard_log.ctx.ts"],"sourcesContent":["import { record } from 'type-plus'\nimport type { LogStore } from './log_store.js'\nimport type { LogMethodNames, StandardLogInstance } from './types.js'\n\nexport const ctx: {\n\tconfigured?: boolean\n\tgsl?: { store: LogStore; standardLog: StandardLogInstance<LogMethodNames> }\n} = record()\n"],"mappings":";;AAIA,MAAa,OAAA,sBAGTA,CAAAA,CAAAA,OAAAA,CAAO"}
@@ -1,17 +1,19 @@
1
- import { type LogStore } from './log_store.js';
2
- import type { LogMethodNames, Logger, LoggerOptions, StandardLogInstance, StandardLogOptions } from './types.js';
3
- export interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {
4
- }
5
- export declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
6
- export declare function createStandardLogClosure<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): {
7
- store: LogStore;
8
- standardLog: StandardLog<N>;
1
+ import { LogMethodNames, Logger, LoggerOptions, StandardLogInstance, StandardLogOptions } from "./types.js";
2
+ import { LogStore } from "./log_store.js";
3
+ //#region ts/standard_log.d.ts
4
+ interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {}
5
+ declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
6
+ declare function createStandardLogClosure<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): {
7
+ store: LogStore;
8
+ standardLog: StandardLog<N>;
9
9
  };
10
10
  /**
11
11
  * Suppress logging within the code block.
12
12
  */
13
- export declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
14
- export type GetLogger<N extends string = LogMethodNames> = (id: string, options?: LoggerOptions) => Logger<LogMethodNames | N>;
15
- export declare function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions): Logger<LogMethodNames | N>;
16
- export declare function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>): void;
13
+ declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
14
+ type GetLogger<N extends string = LogMethodNames> = (id: string, options?: LoggerOptions) => Logger<LogMethodNames | N>;
15
+ declare function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
16
+ declare function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>): void;
17
+ //#endregion
18
+ export { GetLogger, StandardLog, configGlobal, createStandardLog, createStandardLogClosure, getLogger, suppressLogs };
17
19
  //# sourceMappingURL=standard_log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard_log.d.ts","sourceRoot":"","sources":["../ts/standard_log.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAG9D,OAAO,KAAK,EACX,cAAc,EACd,MAAM,EACN,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,YAAY,CAAA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