standard-log 12.1.2 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +8 -8
  2. package/cjs/console.d.ts.map +1 -1
  3. package/cjs/console.js +8 -11
  4. package/cjs/console.js.map +1 -1
  5. package/cjs/errors.d.ts +1 -1
  6. package/cjs/errors.d.ts.map +1 -1
  7. package/cjs/errors.js.map +1 -1
  8. package/cjs/formatter.d.ts.map +1 -1
  9. package/cjs/formatter.js +5 -7
  10. package/cjs/formatter.js.map +1 -1
  11. package/cjs/index.d.ts +2 -2
  12. package/cjs/index.d.ts.map +1 -1
  13. package/cjs/index.js.map +1 -1
  14. package/cjs/log_levels.js +5 -5
  15. package/cjs/log_levels.js.map +1 -1
  16. package/cjs/log_store.js +2 -3
  17. package/cjs/log_store.js.map +1 -1
  18. package/cjs/logger.d.ts +1 -1
  19. package/cjs/logger.d.ts.map +1 -1
  20. package/cjs/logger.js +1 -2
  21. package/cjs/logger.js.map +1 -1
  22. package/cjs/memory.d.ts.map +1 -1
  23. package/cjs/memory.js +6 -9
  24. package/cjs/memory.js.map +1 -1
  25. package/cjs/platform.browser.d.ts.map +1 -1
  26. package/cjs/platform.d.ts.map +1 -1
  27. package/cjs/platform.js +2 -2
  28. package/cjs/platform.js.map +1 -1
  29. package/cjs/standard_log.d.ts +1 -1
  30. package/cjs/standard_log.d.ts.map +1 -1
  31. package/cjs/standard_log.js +5 -6
  32. package/cjs/standard_log.js.map +1 -1
  33. package/cjs/standard_log.testing.js +1 -2
  34. package/cjs/standard_log.testing.js.map +1 -1
  35. package/cjs/testing/index.d.ts +2 -2
  36. package/cjs/testing/index.d.ts.map +1 -1
  37. package/cjs/testing/index.js.map +1 -1
  38. package/cjs/types.d.ts +1 -1
  39. package/cjs/types.d.ts.map +1 -1
  40. package/cjs/types.js.map +1 -1
  41. package/dist/standard-log.es5.js +1643 -1199
  42. package/dist/standard-log.es5.js.gz +0 -0
  43. package/dist/standard-log.es5.js.map +1 -1
  44. package/dist/standard-log.es5.js.map.gz +0 -0
  45. package/dist/standard-log.esm.js +273 -303
  46. package/dist/standard-log.esm.js.gz +0 -0
  47. package/dist/standard-log.esm.js.map +1 -1
  48. package/dist/standard-log.esm.js.map.gz +0 -0
  49. package/esm/console.d.ts.map +1 -1
  50. package/esm/console.js +7 -9
  51. package/esm/console.js.map +1 -1
  52. package/esm/errors.d.ts +1 -1
  53. package/esm/errors.d.ts.map +1 -1
  54. package/esm/errors.js.map +1 -1
  55. package/esm/formatter.d.ts.map +1 -1
  56. package/esm/formatter.js +1 -2
  57. package/esm/formatter.js.map +1 -1
  58. package/esm/index.d.ts +2 -2
  59. package/esm/index.d.ts.map +1 -1
  60. package/esm/index.js.map +1 -1
  61. package/esm/log_levels.js +2 -2
  62. package/esm/log_levels.js.map +1 -1
  63. package/esm/logger.d.ts +1 -1
  64. package/esm/logger.d.ts.map +1 -1
  65. package/esm/logger.js.map +1 -1
  66. package/esm/memory.d.ts.map +1 -1
  67. package/esm/memory.js +3 -5
  68. package/esm/memory.js.map +1 -1
  69. package/esm/platform.browser.d.ts.map +1 -1
  70. package/esm/platform.d.ts.map +1 -1
  71. package/esm/platform.js +1 -1
  72. package/esm/platform.js.map +1 -1
  73. package/esm/standard_log.d.ts +1 -1
  74. package/esm/standard_log.d.ts.map +1 -1
  75. package/esm/standard_log.js.map +1 -1
  76. package/esm/standard_log.testing.js.map +1 -1
  77. package/esm/testing/index.d.ts +2 -2
  78. package/esm/testing/index.d.ts.map +1 -1
  79. package/esm/testing/index.js.map +1 -1
  80. package/esm/types.d.ts +1 -1
  81. package/esm/types.d.ts.map +1 -1
  82. package/esm/types.js.map +1 -1
  83. package/package.json +24 -36
  84. package/ts/console.ts +7 -8
  85. package/ts/errors.ts +5 -2
  86. package/ts/formatter.ts +1 -2
  87. package/ts/index.ts +3 -3
  88. package/ts/log_levels.ts +2 -2
  89. package/ts/logger.ts +14 -7
  90. package/ts/memory.ts +3 -5
  91. package/ts/platform.ts +1 -1
  92. package/ts/standard_log.ts +2 -2
  93. package/ts/testing/index.ts +3 -3
  94. package/ts/types.ts +1 -1
package/README.md CHANGED
@@ -48,7 +48,7 @@ log.debug('debug message')
48
48
  log.on(logLevels.trace, () => prettify(someValue))
49
49
  ```
50
50
 
51
- ![Rendering example](https://raw.githubusercontent.com/unional/standard-log/main/images/color-log.png)
51
+ ![Rendering example](https://raw.githubusercontent.com/cyberuni/standard-log/main/images/color-log.png)
52
52
 
53
53
  (above is logged with `standard-log-color`)
54
54
 
@@ -190,16 +190,16 @@ But in micro-app situation, the library can be shared, and each application can
190
190
  In general, using this global instance should be avoided.
191
191
  It is the main driving force for 9.0.
192
192
 
193
- [codecov-image]: https://codecov.io/gh/unional/standard-log/branch/master/graph/badge.svg
194
- [codecov-url]: https://codecov.io/gh/unional/standard-log
193
+ [codecov-image]: https://codecov.io/gh/cyberuni/standard-log/branch/main/graph/badge.svg
194
+ [codecov-url]: https://codecov.io/gh/cyberuni/standard-log
195
195
  [downloads-image]: https://img.shields.io/npm/dm/standard-log.svg?style=flat
196
196
  [downloads-url]: https://npmjs.org/package/standard-log
197
- [github-action-url]: https://github.com/unional/standard-log/actions
198
- [github-nodejs]: https://github.com/unional/standard-log/workflows/release/badge.svg
197
+ [github-action-url]: https://github.com/cyberuni/standard-log/actions
198
+ [github-nodejs]: https://github.com/cyberuni/standard-log/actions/workflows/release.yml/badge.svg
199
199
  [npm-image]: https://img.shields.io/npm/v/standard-log.svg?style=flat
200
200
  [npm-url]: https://www.npmjs.com/package/standard-log
201
- [standard-log-color]: https://github.com/unional/standard-log/tree/master/packages/color
202
- [standard-log-syslog]: https://github.com/unional/standard-log/tree/master/packages/syslog
203
- [standard-log]: https://github.com/unional/standard-log
201
+ [standard-log-color]: https://github.com/cyberuni/standard-log/tree/main/packages/color
202
+ [standard-log-syslog]: https://github.com/cyberuni/standard-log/tree/main/packages/syslog
203
+ [standard-log]: https://github.com/cyberuni/standard-log
204
204
  [vscode-image]: https://img.shields.io/badge/vscode-ready-green.svg
205
205
  [vscode-url]: https://code.visualstudio.com/
@@ -1 +1 @@
1
- {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../ts/console.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAY,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEtG,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,uCAc5C;AAiCD,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC,CAAA;AACrD,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAA;AAC9E,MAAM,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAA;AAEjE,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CAqBhG"}
1
+ {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../ts/console.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAY,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEtG,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,uCAc5C;AAgCD,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC,CAAA;AACrD,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAA;AAC9E,MAAM,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAA;AAEjE,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CAqBhG"}
package/cjs/console.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createConsoleLogReporter = exports.toConsoleMethod = void 0;
3
+ exports.toConsoleMethod = toConsoleMethod;
4
+ exports.createConsoleLogReporter = createConsoleLogReporter;
4
5
  var type_plus_1 = require("type-plus");
5
6
  var formatter_js_1 = require("./formatter.js");
6
7
  var log_levels_js_1 = require("./log_levels.js");
@@ -20,7 +21,6 @@ function toConsoleMethod(level) {
20
21
  return 'debug';
21
22
  }
22
23
  }
23
- exports.toConsoleMethod = toConsoleMethod;
24
24
  // istanbul ignore next
25
25
  /* eslint-disable no-console */
26
26
  function buildPolyfillConsole() {
@@ -36,14 +36,12 @@ function buildPolyfillConsole() {
36
36
  error: (typeof console.error === 'function' ? console.error : console.log).bind(console)
37
37
  };
38
38
  }
39
- else {
40
- return {
41
- debug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),
42
- info: buildFn(typeof console.info === 'function' ? 'info' : 'log'),
43
- warn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),
44
- error: buildFn(typeof console.error === 'function' ? 'error' : 'log')
45
- };
46
- }
39
+ return {
40
+ debug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),
41
+ info: buildFn(typeof console.info === 'function' ? 'info' : 'log'),
42
+ warn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),
43
+ error: buildFn(typeof console.error === 'function' ? 'error' : 'log')
44
+ };
47
45
  }
48
46
  // istanbul ignore next
49
47
  function buildFn(name) {
@@ -79,5 +77,4 @@ function createConsoleLogReporter(options) {
79
77
  }
80
78
  });
81
79
  }
82
- exports.createConsoleLogReporter = createConsoleLogReporter;
83
80
  //# sourceMappingURL=console.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"console.js","sourceRoot":"","sources":["../ts/console.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,+CAAiD;AACjD,iDAA2C;AAC3C,6CAAwC;AAGxC,SAAgB,eAAe,CAAC,KAAa;IAC5C,Q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D,OAAO,EAAE,sBAAQ,CAAC,OAAO;QACzB,KAAK,YAAC,KAAe;;YACpB,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,OAAM;YACpC,IAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;YAC/B,IAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAC3C,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,MAAM,CAAC,WAAI,MAAM,EAAC;QAChC,CAAC;KACD,CAAC,CAAA;AACH,CAAC;AArBD,4DAqBC","sourcesContent":["import { unpartial } from 'type-plus'\nimport { consoleFormatter } from './formatter.js'\nimport { logLevels } from './log_levels.js'\nimport { polyfill } from './platform.js'\nimport type { ConsoleLike, LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport function toConsoleMethod(level: number) {\n\tswitch (true) {\n\t\t// edge case in case none is somehow written\n\t\tcase level <= 0:\n\t\t\treturn 'debug'\n\t\tcase level <= logLevels.error:\n\t\t\treturn 'error'\n\t\tcase level <= logLevels.warn:\n\t\t\treturn 'warn'\n\t\tcase level <= logLevels.info:\n\t\t\treturn 'info'\n\t\tdefault:\n\t\t\treturn 'debug'\n\t}\n}\n\n// istanbul ignore next\n/* eslint-disable no-console */\nfunction buildPolyfillConsole() {\n\t// old phantomjs does not have bind function\n\tconst hasBind = !!console.log.bind as boolean\n\tif (hasBind) {\n\t\treturn {\n\t\t\t// the `typeof` guards against IE where `console.log.apply()`\n\t\t\t// results in error `Object doesn't support property or method 'apply'`\n\t\t\tdebug: (typeof console.info === 'function' ? console.debug : console.log).bind(console),\n\t\t\tinfo: (typeof console.info === 'function' ? console.info : console.log).bind(console),\n\t\t\twarn: (typeof console.warn === 'function' ? console.warn : console.log).bind(console),\n\t\t\terror: (typeof console.error === 'function' ? console.error : console.log).bind(console)\n\t\t}\n\t} else {\n\t\treturn {\n\t\t\tdebug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),\n\t\t\tinfo: buildFn(typeof console.info === 'function' ? 'info' : 'log'),\n\t\t\twarn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),\n\t\t\terror: buildFn(typeof console.error === 'function' ? 'error' : 'log')\n\t\t}\n\t}\n}\n\n// istanbul ignore next\nfunction buildFn(name: 'debug' | 'info' | 'warn' | 'error' | 'log') {\n\treturn function (...args: any[]) {\n\t\tconsole[name](...args)\n\t}\n}\n\nexport type ConsoleLogFormatter = LogFormatter<any[]>\nexport type ConsoleLogReporter = LogReporter<any[]> & { console: ConsoleLike }\nexport type ConsoleLogReporterOptions = LogReporterOptions<any[]>\n\nexport function createConsoleLogReporter(options?: ConsoleLogReporterOptions): ConsoleLogReporter {\n\tconst { id, formatter, filter } = unpartial({ id: 'console', formatter: consoleFormatter }, options)\n\tif (!polyfill.console) polyfill.console = buildPolyfillConsole()\n\n\treturn Object.freeze({\n\t\tid,\n\t\tisConsoleReporter: true,\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\tconsole: polyfill.console,\n\t\twrite(entry: LogEntry) {\n\t\t\tif (filter && !filter(entry)) return\n\t\t\tconst values = formatter(entry)\n\t\t\tconst method = toConsoleMethod(entry.level)\n\t\t\tthis.console[method](...values)\n\t\t}\n\t})\n}\n"]}
1
+ {"version":3,"file":"console.js","sourceRoot":"","sources":["../ts/console.ts"],"names":[],"mappings":";;AAMA,0CAcC;AAoCD,4DAqBC;AA7ED,uCAAqC;AACrC,+CAAiD;AACjD,iDAA2C;AAC3C,6CAAwC;AAGxC,SAAgB,eAAe,CAAC,KAAa;IAC5C,QAAQ,IAAI,EAAE,CAAC;QACd,4CAA4C;QAC5C,KAAK,KAAK,IAAI,CAAC;YACd,OAAO,OAAO,CAAA;QACf,KAAK,KAAK,IAAI,yBAAS,CAAC,KAAK;YAC5B,OAAO,OAAO,CAAA;QACf,KAAK,KAAK,IAAI,yBAAS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IAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAC3C,CAAA,KAAA,IAAI,CAAC,OAAO,CAAA,CAAC,MAAM,CAAC,WAAI,MAAM,EAAC;QAChC,CAAC;KACD,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { unpartial } from 'type-plus'\nimport { consoleFormatter } from './formatter.js'\nimport { logLevels } from './log_levels.js'\nimport { polyfill } from './platform.js'\nimport type { ConsoleLike, LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport function toConsoleMethod(level: number) {\n\tswitch (true) {\n\t\t// edge case in case none is somehow written\n\t\tcase level <= 0:\n\t\t\treturn 'debug'\n\t\tcase level <= logLevels.error:\n\t\t\treturn 'error'\n\t\tcase level <= logLevels.warn:\n\t\t\treturn 'warn'\n\t\tcase level <= logLevels.info:\n\t\t\treturn 'info'\n\t\tdefault:\n\t\t\treturn 'debug'\n\t}\n}\n\n// istanbul ignore next\n/* eslint-disable no-console */\nfunction buildPolyfillConsole() {\n\t// old phantomjs does not have bind function\n\tconst hasBind = !!console.log.bind as boolean\n\tif (hasBind) {\n\t\treturn {\n\t\t\t// the `typeof` guards against IE where `console.log.apply()`\n\t\t\t// results in error `Object doesn't support property or method 'apply'`\n\t\t\tdebug: (typeof console.info === 'function' ? console.debug : console.log).bind(console),\n\t\t\tinfo: (typeof console.info === 'function' ? console.info : console.log).bind(console),\n\t\t\twarn: (typeof console.warn === 'function' ? console.warn : console.log).bind(console),\n\t\t\terror: (typeof console.error === 'function' ? console.error : console.log).bind(console)\n\t\t}\n\t}\n\treturn {\n\t\tdebug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),\n\t\tinfo: buildFn(typeof console.info === 'function' ? 'info' : 'log'),\n\t\twarn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),\n\t\terror: buildFn(typeof console.error === 'function' ? 'error' : 'log')\n\t}\n}\n\n// istanbul ignore next\nfunction buildFn(name: 'debug' | 'info' | 'warn' | 'error' | 'log') {\n\treturn (...args: any[]) => {\n\t\tconsole[name](...args)\n\t}\n}\n\nexport type ConsoleLogFormatter = LogFormatter<any[]>\nexport type ConsoleLogReporter = LogReporter<any[]> & { console: ConsoleLike }\nexport type ConsoleLogReporterOptions = LogReporterOptions<any[]>\n\nexport function createConsoleLogReporter(options?: ConsoleLogReporterOptions): ConsoleLogReporter {\n\tconst { id, formatter, filter } = unpartial({ id: 'console', formatter: consoleFormatter }, options)\n\tif (!polyfill.console) polyfill.console = buildPolyfillConsole()\n\n\treturn Object.freeze({\n\t\tid,\n\t\tisConsoleReporter: true,\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\tconsole: polyfill.console,\n\t\twrite(entry: LogEntry) {\n\t\t\tif (filter && !filter(entry)) return\n\t\t\tconst values = formatter(entry)\n\t\t\tconst method = toConsoleMethod(entry.level)\n\t\t\tthis.console[method](...values)\n\t\t}\n\t})\n}\n"]}
package/cjs/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IsoError, ModuleError } from 'iso-error';
1
+ import { type IsoError, ModuleError } from 'iso-error';
2
2
  /**
3
3
  * @deprecated No longer used since 11.2.0
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEjD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;gBACpC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG3D;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,gBAAgB;IAC3B,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAGzD"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEtD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;gBACpC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG3D;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,gBAAgB;IAEtC,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAI3B"}
package/cjs/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAiD;AAEjD;;GAEG;AACH;IAAsC,oCAAW;IAChD,0BAAY,WAAmB,EAAE,OAA0B;eAC1D,kBAAM,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC;IAC5C,CAAC;IACF,uBAAC;AAAD,CAAC,AAJD,CAAsC,uBAAW,GAIhD;AAJY,4CAAgB;AAM7B;;GAEG;AACH;IAA+B,6BAAgB;IAC9C,mBAAmB,EAAU,EAAE,OAA0B;QAAzD,YACC,kBAAM,yFAAkF,EAAE,CAAE,EAAE,OAAO,CAAC,SACtG;QAFW;;;;mBAAO,EAAE;WAAQ;;IAE7B,CAAC;IACF,gBAAC;AAAD,CAAC,AAJD,CAA+B,gBAAgB,GAI9C;AAJY,8BAAS","sourcesContent":["import { IsoError, ModuleError } from 'iso-error'\n\n/**\n * @deprecated No longer used since 11.2.0\n */\nexport class StandardLogError extends ModuleError {\n\tconstructor(description: string, options?: IsoError.Options) {\n\t\tsuper('standard-log', description, options)\n\t}\n}\n\n/**\n * @deprecated no longer used since 11.2.0\n */\nexport class InvalidId extends StandardLogError {\n\tconstructor(public id: string, options?: IsoError.Options) {\n\t\tsuper(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options)\n\t}\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAsD;AAEtD;;GAEG;AACH;IAAsC,oCAAW;IAChD,0BAAY,WAAmB,EAAE,OAA0B;QAC1D,OAAA,MAAK,YAAC,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,SAAA;IAC5C,CAAC;IACF,uBAAC;AAAD,CAAC,AAJD,CAAsC,uBAAW,GAIhD;AAJY,4CAAgB;AAM7B;;GAEG;AACH;IAA+B,6BAAgB;IAC9C,mBACQ,EAAU,EACjB,OAA0B;QAE1B,YAAA,MAAK,YAAC,yFAAkF,EAAE,CAAE,EAAE,OAAO,CAAC,SAAA;QAHtG;;;;mBAAO,EAAE;WAAQ;;IAIlB,CAAC;IACF,gBAAC;AAAD,CAAC,AAPD,CAA+B,gBAAgB,GAO9C;AAPY,8BAAS","sourcesContent":["import { type IsoError, ModuleError } from 'iso-error'\n\n/**\n * @deprecated No longer used since 11.2.0\n */\nexport class StandardLogError extends ModuleError {\n\tconstructor(description: string, options?: IsoError.Options) {\n\t\tsuper('standard-log', description, options)\n\t}\n}\n\n/**\n * @deprecated no longer used since 11.2.0\n */\nexport class InvalidId extends StandardLogError {\n\tconstructor(\n\t\tpublic id: string,\n\t\toptions?: IsoError.Options\n\t) {\n\t\tsuper(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options)\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAA;AAExD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,CAAC,SAAS,EAAE,IAAI,KAAK,MAAM,GAAG,SAAS,CAgBzG;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAE3C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,SAEzE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,SAElD"}
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAA;AAExD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,CAAC,SAAS,EAAE,IAAI,KAAK,MAAM,GAAG,SAAS,CAgBzG;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAE3C;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,SAEzE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,SAElD"}
package/cjs/formatter.js CHANGED
@@ -12,9 +12,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.consoleFormatter = exports.plainLogFormatter = exports.formatLogLevel = exports.createTimestampFormatter = void 0;
15
+ exports.createTimestampFormatter = createTimestampFormatter;
16
+ exports.formatLogLevel = formatLogLevel;
17
+ exports.plainLogFormatter = plainLogFormatter;
18
+ exports.consoleFormatter = consoleFormatter;
16
19
  var ms_1 = __importDefault(require("ms"));
17
- var upper_case_1 = require("upper-case");
18
20
  var log_levels_js_1 = require("./log_levels.js");
19
21
  function createTimestampFormatter(format) {
20
22
  switch (format) {
@@ -33,11 +35,9 @@ function createTimestampFormatter(format) {
33
35
  }
34
36
  }
35
37
  }
36
- exports.createTimestampFormatter = createTimestampFormatter;
37
38
  function formatLogLevel(level) {
38
- return "(".concat((0, upper_case_1.upperCase)((0, log_levels_js_1.toLogLevelName)(level)), ")");
39
+ return "(".concat((0, log_levels_js_1.toLogLevelName)(level).toUpperCase(), ")");
39
40
  }
40
- exports.formatLogLevel = formatLogLevel;
41
41
  /**
42
42
  * Formats log entry as plain text with the following format:
43
43
  * `timestamp id level ...args`
@@ -48,7 +48,6 @@ function plainLogFormatter(_a) {
48
48
  var id = _a.id, level = _a.level, args = _a.args, timestamp = _a.timestamp;
49
49
  return __spreadArray([timestamp.toISOString(), id, formatLogLevel(level)], args, true);
50
50
  }
51
- exports.plainLogFormatter = plainLogFormatter;
52
51
  /**
53
52
  * Formats log entry like default console log.
54
53
  */
@@ -56,5 +55,4 @@ function consoleFormatter(_a) {
56
55
  var args = _a.args;
57
56
  return args;
58
57
  }
59
- exports.consoleFormatter = consoleFormatter;
60
58
  //# sourceMappingURL=formatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAAmB;AACnB,yCAAsC;AACtC,iDAAgD;AAKhD,SAAgB,wBAAwB,CAAC,MAAuB;IAC/D,QAAQ,MAAM,EAAE;QACf,KAAK,MAAM;YACV,OAAO,UAAC,UAAgB,IAAK,OAAA,SAAS,EAAT,CAAS,CAAA;QACvC,KAAK,KAAK;YACT,OAAO,UAAC,SAAe,IAAK,OAAA,SAAS,CAAC,WAAW,EAAE,EAAvB,CAAuB,CAAA;QACpD,KAAK,SAAS,CAAC,CAAC;YACf,IAAI,UAAgB,CAAA;YACpB,OAAO,UAAC,SAAe;gBACtB,IAAM,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,CAAA;gBACnC,IAAM,MAAM,GAAG,IAAA,YAAE,EAAC,UAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,UAAQ,CAAC,CAAA;gBAClE,UAAQ,GAAG,OAAO,CAAA;gBAClB,OAAO,MAAM,CAAA;YACd,CAAC,CAAA;SACD;KACD;AACF,CAAC;AAhBD,4DAgBC;AAED,SAAgB,cAAc,CAAC,KAAa;IAC3C,OAAO,WAAI,IAAA,sBAAS,EAAC,IAAA,8BAAc,EAAC,KAAK,CAAC,CAAC,MAAG,CAAA;AAC/C,CAAC;AAFD,wCAEC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,EAAwC;QAAtC,EAAE,QAAA,EAAE,KAAK,WAAA,EAAE,IAAI,UAAA,EAAE,SAAS,eAAA;IAC7D,sBAAQ,SAAS,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,GAAK,IAAI,QAAC;AACrE,CAAC;AAFD,8CAEC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,EAAkB;QAAhB,IAAI,UAAA;IACtC,OAAO,IAAI,CAAA;AACZ,CAAC;AAFD,4CAEC","sourcesContent":["import ms from 'ms'\nimport { upperCase } from 'upper-case'\nimport { toLogLevelName } from './log_levels.js'\nimport type { LogEntry } from './types.js'\n\nexport type TimestampFormat = 'none' | 'iso' | 'elapsed'\n\nexport function createTimestampFormatter(format: TimestampFormat): (timestamp: Date) => string | undefined {\n\tswitch (format) {\n\t\tcase 'none':\n\t\t\treturn (_timestamp: Date) => undefined\n\t\tcase 'iso':\n\t\t\treturn (timestamp: Date) => timestamp.toISOString()\n\t\tcase 'elapsed': {\n\t\t\tlet lastTick: number\n\t\t\treturn (timestamp: Date) => {\n\t\t\t\tconst newTick = timestamp.getTime()\n\t\t\t\tconst result = ms(lastTick === undefined ? 0 : newTick - lastTick)\n\t\t\t\tlastTick = newTick\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function formatLogLevel(level: number) {\n\treturn `(${upperCase(toLogLevelName(level))})`\n}\n\n/**\n * Formats log entry as plain text with the following format:\n * `timestamp id level ...args`\n *\n * This is typically useful for writing logs to file\n */\nexport function plainLogFormatter({ id, level, args, timestamp }: LogEntry) {\n\treturn [timestamp.toISOString(), id, formatLogLevel(level), ...args]\n}\n\n/**\n * Formats log entry like default console log.\n */\nexport function consoleFormatter({ args }: LogEntry) {\n\treturn args\n}\n"]}
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,4DAgBC;AAED,wCAEC;AAQD,8CAEC;AAKD,4CAEC;AA3CD,0CAAmB;AACnB,iDAAgD;AAKhD,SAAgB,wBAAwB,CAAC,MAAuB;IAC/D,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,MAAM;YACV,OAAO,UAAC,UAAgB,IAAK,OAAA,SAAS,EAAT,CAAS,CAAA;QACvC,KAAK,KAAK;YACT,OAAO,UAAC,SAAe,IAAK,OAAA,SAAS,CAAC,WAAW,EAAE,EAAvB,CAAuB,CAAA;QACpD,KAAK,SAAS,CAAC,CAAC,CAAC;YAChB,IAAI,UAAgB,CAAA;YACpB,OAAO,UAAC,SAAe;gBACtB,IAAM,OAAO,GAAG,SAAS,CAAC,OAAO,EAAE,CAAA;gBACnC,IAAM,MAAM,GAAG,IAAA,YAAE,EAAC,UAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,UAAQ,CAAC,CAAA;gBAClE,UAAQ,GAAG,OAAO,CAAA;gBAClB,OAAO,MAAM,CAAA;YACd,CAAC,CAAA;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAED,SAAgB,cAAc,CAAC,KAAa;IAC3C,OAAO,WAAI,IAAA,8BAAc,EAAC,KAAK,CAAC,CAAC,WAAW,EAAE,MAAG,CAAA;AAClD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,EAAwC;QAAtC,EAAE,QAAA,EAAE,KAAK,WAAA,EAAE,IAAI,UAAA,EAAE,SAAS,eAAA;IAC7D,sBAAQ,SAAS,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,GAAK,IAAI,QAAC;AACrE,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,EAAkB;QAAhB,IAAI,UAAA;IACtC,OAAO,IAAI,CAAA;AACZ,CAAC","sourcesContent":["import ms from 'ms'\nimport { toLogLevelName } from './log_levels.js'\nimport type { LogEntry } from './types.js'\n\nexport type TimestampFormat = 'none' | 'iso' | 'elapsed'\n\nexport function createTimestampFormatter(format: TimestampFormat): (timestamp: Date) => string | undefined {\n\tswitch (format) {\n\t\tcase 'none':\n\t\t\treturn (_timestamp: Date) => undefined\n\t\tcase 'iso':\n\t\t\treturn (timestamp: Date) => timestamp.toISOString()\n\t\tcase 'elapsed': {\n\t\t\tlet lastTick: number\n\t\t\treturn (timestamp: Date) => {\n\t\t\t\tconst newTick = timestamp.getTime()\n\t\t\t\tconst result = ms(lastTick === undefined ? 0 : newTick - lastTick)\n\t\t\t\tlastTick = newTick\n\t\t\t\treturn result\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function formatLogLevel(level: number) {\n\treturn `(${toLogLevelName(level).toUpperCase()})`\n}\n\n/**\n * Formats log entry as plain text with the following format:\n * `timestamp id level ...args`\n *\n * This is typically useful for writing logs to file\n */\nexport function plainLogFormatter({ id, level, args, timestamp }: LogEntry) {\n\treturn [timestamp.toISOString(), id, formatLogLevel(level), ...args]\n}\n\n/**\n * Formats log entry like default console log.\n */\nexport function consoleFormatter({ args }: LogEntry) {\n\treturn args\n}\n"]}
package/cjs/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from './errors.js';
3
3
  export * from './formatter.js';
4
4
  export * from './log_levels.js';
5
5
  export * from './memory.js';
6
- export { configGlobal, createStandardLog, getLogger, suppressLogs } from './standard_log.js';
7
6
  export type { GetLogger, StandardLog } from './standard_log.js';
8
- export type { ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, LogLevel, LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, Logger, LoggerOptions, ReporterFilter, StandardLogInstance, StandardLogOptions } from './types.js';
7
+ export { configGlobal, createStandardLog, getLogger, suppressLogs } from './standard_log.js';
8
+ export type { ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, Logger, LoggerOptions, LogLevel, LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, ReporterFilter, StandardLogInstance, StandardLogOptions } from './types.js';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC5F,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/D,YAAY,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,SAAS,EACT,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,MAAM,EACN,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC5F,YAAY,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,WAAW,EACX,MAAM,EACN,aAAa,EACb,QAAQ,EACR,aAAa,EACb,SAAS,EACT,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,YAAY,CAAA"}
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,8CAA2B;AAC3B,iDAA8B;AAC9B,kDAA+B;AAC/B,8CAA2B;AAC3B,qDAA4F;AAAnF,+GAAA,YAAY,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAAE,4GAAA,SAAS,OAAA;AAAE,+GAAA,YAAY,OAAA","sourcesContent":["export * from './console.js'\nexport * from './errors.js'\nexport * from './formatter.js'\nexport * from './log_levels.js'\nexport * from './memory.js'\nexport { configGlobal, createStandardLog, getLogger, suppressLogs } from './standard_log.js'\nexport type { GetLogger, StandardLog } from './standard_log.js'\nexport type {\n\tConsoleLike,\n\tLogEntry,\n\tLogFilter,\n\tLogFormatter,\n\tLogFunction,\n\tLogLevel,\n\tLogLevelEntry,\n\tLogMethod,\n\tLogMethodNames,\n\tLogReporter,\n\tLogReporterOptions,\n\tLogger,\n\tLoggerOptions,\n\tReporterFilter,\n\tStandardLogInstance,\n\tStandardLogOptions\n} from './types.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,8CAA2B;AAC3B,iDAA8B;AAC9B,kDAA+B;AAC/B,8CAA2B;AAE3B,qDAA4F;AAAnF,+GAAA,YAAY,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAAE,4GAAA,SAAS,OAAA;AAAE,+GAAA,YAAY,OAAA","sourcesContent":["export * from './console.js'\nexport * from './errors.js'\nexport * from './formatter.js'\nexport * from './log_levels.js'\nexport * from './memory.js'\nexport type { GetLogger, StandardLog } from './standard_log.js'\nexport { configGlobal, createStandardLog, getLogger, suppressLogs } from './standard_log.js'\nexport type {\n\tConsoleLike,\n\tLogEntry,\n\tLogFilter,\n\tLogFormatter,\n\tLogFunction,\n\tLogger,\n\tLoggerOptions,\n\tLogLevel,\n\tLogLevelEntry,\n\tLogMethod,\n\tLogMethodNames,\n\tLogReporter,\n\tLogReporterOptions,\n\tReporterFilter,\n\tStandardLogInstance,\n\tStandardLogOptions\n} from './types.js'\n"]}
package/cjs/log_levels.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_LOG_METHOD_NAMES = exports.toLogLevel = exports.toLogLevelName = exports.logLevels = void 0;
3
+ exports.DEFAULT_LOG_METHOD_NAMES = exports.logLevels = void 0;
4
+ exports.toLogLevelName = toLogLevelName;
5
+ exports.toLogLevel = toLogLevel;
4
6
  exports.logLevels = {
5
7
  /**
6
8
  * none: 0
@@ -66,11 +68,11 @@ exports.logLevels = {
66
68
  *
67
69
  * trace -> planck
68
70
  */
69
- planck: Infinity,
71
+ planck: Number.POSITIVE_INFINITY,
70
72
  /**
71
73
  * all: Infinity
72
74
  */
73
- all: Infinity
75
+ all: Number.POSITIVE_INFINITY
74
76
  };
75
77
  /**
76
78
  * Convert default log level value to log level name.
@@ -96,14 +98,12 @@ function toLogLevelName(level) {
96
98
  return 'trace';
97
99
  return 'planck';
98
100
  }
99
- exports.toLogLevelName = toLogLevelName;
100
101
  /**
101
102
  * Convert default log level name to log level value.
102
103
  */
103
104
  function toLogLevel(name) {
104
105
  return exports.logLevels[name.toLocaleLowerCase()];
105
106
  }
106
- exports.toLogLevel = toLogLevel;
107
107
  exports.DEFAULT_LOG_METHOD_NAMES = [
108
108
  'emergency',
109
109
  'alert',
@@ -1 +1 @@
1
- {"version":3,"file":"log_levels.js","sourceRoot":"","sources":["../ts/log_levels.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,CAAU;IAChB;;;;OAIG;IACH,SAAS,EAAE,GAAY;IACvB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;OAIG;IACH,QAAQ,EAAE,GAAY;IACtB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;OAIG;IACH,IAAI,EAAE,GAAY;IAClB;;;;OAIG;IACH,MAAM,EAAE,GAAY;IACpB;;;;OAIG;IACH,IAAI,EAAE,GAAY;IAClB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;;OAKG;IACH,MAAM,EAAE,QAAQ;IAChB;;OAEG;IACH,GAAG,EAAE,QAAQ;CACb,CAAA;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAa;IAC3C,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,WAAW,CAAA;IACpC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,UAAU,CAAA;IACnC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,QAAQ,CAAA;IACjC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,OAAO,QAAQ,CAAA;AAChB,CAAC;AAXD,wCAWC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,IAAY;IACtC,OAAQ,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;AACpD,CAAC;AAFD,gCAEC;AAEY,QAAA,wBAAwB,GAAa;IACjD,WAAW;IACX,OAAO;IACP,UAAU;IACV,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,OAAO;IACP,QAAQ;CACR,CAAA","sourcesContent":["export const logLevels = {\n\t/**\n\t * none: 0\n\t */\n\tnone: 0 as const,\n\t/**\n\t * emergency: 100\n\t *\n\t * emergency -> alert\n\t */\n\temergency: 100 as const,\n\t/**\n\t * alert: 200\n\t *\n\t * emergency -> alert -> critical\n\t */\n\talert: 200 as const,\n\t/**\n\t * critical: 300\n\t *\n\t * alert -> critical -> error\n\t */\n\tcritical: 300 as const,\n\t/**\n\t * error: 400\n\t *\n\t * critical -> error -> warn\n\t */\n\terror: 400 as const,\n\t/**\n\t * warn: 500\n\t *\n\t * error -> warn -> notice\n\t */\n\twarn: 500 as const,\n\t/**\n\t * notice: 600\n\t *\n\t * warn -> notice -> info\n\t */\n\tnotice: 600 as const,\n\t/**\n\t * info: 700\n\t *\n\t * notice -> info -> debug\n\t */\n\tinfo: 700 as const,\n\t/**\n\t * debug: 800\n\t *\n\t * info -> debug -> trace\n\t */\n\tdebug: 800 as const,\n\t/**\n\t * trace: 900\n\t *\n\t * debug -> trace -> planck\n\t */\n\ttrace: 900 as const,\n\t/**\n\t * planck: Infinity\n\t * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.\n\t *\n\t * trace -> planck\n\t */\n\tplanck: Infinity,\n\t/**\n\t * all: Infinity\n\t */\n\tall: Infinity\n}\n\n/**\n * Convert default log level value to log level name.\n */\nexport function toLogLevelName(level: number) {\n\tif (level <= 100) return 'emergency'\n\tif (level <= 200) return 'alert'\n\tif (level <= 300) return 'critical'\n\tif (level <= 400) return 'error'\n\tif (level <= 500) return 'warn'\n\tif (level <= 600) return 'notice'\n\tif (level <= 700) return 'info'\n\tif (level <= 800) return 'debug'\n\tif (level <= 900) return 'trace'\n\treturn 'planck'\n}\n\n/**\n * Convert default log level name to log level value.\n */\nexport function toLogLevel(name: string): number | undefined {\n\treturn (logLevels as any)[name.toLocaleLowerCase()]\n}\n\nexport const DEFAULT_LOG_METHOD_NAMES: string[] = [\n\t'emergency',\n\t'alert',\n\t'critical',\n\t'error',\n\t'warn',\n\t'notice',\n\t'info',\n\t'debug',\n\t'trace',\n\t'planck'\n]\n"]}
1
+ {"version":3,"file":"log_levels.js","sourceRoot":"","sources":["../ts/log_levels.ts"],"names":[],"mappings":";;;AA2EA,wCAWC;AAKD,gCAEC;AA7FY,QAAA,SAAS,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,CAAU;IAChB;;;;OAIG;IACH,SAAS,EAAE,GAAY;IACvB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;OAIG;IACH,QAAQ,EAAE,GAAY;IACtB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;OAIG;IACH,IAAI,EAAE,GAAY;IAClB;;;;OAIG;IACH,MAAM,EAAE,GAAY;IACpB;;;;OAIG;IACH,IAAI,EAAE,GAAY;IAClB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;OAIG;IACH,KAAK,EAAE,GAAY;IACnB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC,iBAAiB;IAChC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC,iBAAiB;CAC7B,CAAA;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAa;IAC3C,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,WAAW,CAAA;IACpC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,UAAU,CAAA;IACnC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,QAAQ,CAAA;IACjC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,MAAM,CAAA;IAC/B,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,OAAO,CAAA;IAChC,OAAO,QAAQ,CAAA;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,IAAY;IACtC,OAAQ,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;AACpD,CAAC;AAEY,QAAA,wBAAwB,GAAa;IACjD,WAAW;IACX,OAAO;IACP,UAAU;IACV,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,OAAO;IACP,QAAQ;CACR,CAAA","sourcesContent":["export const logLevels = {\n\t/**\n\t * none: 0\n\t */\n\tnone: 0 as const,\n\t/**\n\t * emergency: 100\n\t *\n\t * emergency -> alert\n\t */\n\temergency: 100 as const,\n\t/**\n\t * alert: 200\n\t *\n\t * emergency -> alert -> critical\n\t */\n\talert: 200 as const,\n\t/**\n\t * critical: 300\n\t *\n\t * alert -> critical -> error\n\t */\n\tcritical: 300 as const,\n\t/**\n\t * error: 400\n\t *\n\t * critical -> error -> warn\n\t */\n\terror: 400 as const,\n\t/**\n\t * warn: 500\n\t *\n\t * error -> warn -> notice\n\t */\n\twarn: 500 as const,\n\t/**\n\t * notice: 600\n\t *\n\t * warn -> notice -> info\n\t */\n\tnotice: 600 as const,\n\t/**\n\t * info: 700\n\t *\n\t * notice -> info -> debug\n\t */\n\tinfo: 700 as const,\n\t/**\n\t * debug: 800\n\t *\n\t * info -> debug -> trace\n\t */\n\tdebug: 800 as const,\n\t/**\n\t * trace: 900\n\t *\n\t * debug -> trace -> planck\n\t */\n\ttrace: 900 as const,\n\t/**\n\t * planck: Infinity\n\t * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.\n\t *\n\t * trace -> planck\n\t */\n\tplanck: Number.POSITIVE_INFINITY,\n\t/**\n\t * all: Infinity\n\t */\n\tall: Number.POSITIVE_INFINITY\n}\n\n/**\n * Convert default log level value to log level name.\n */\nexport function toLogLevelName(level: number) {\n\tif (level <= 100) return 'emergency'\n\tif (level <= 200) return 'alert'\n\tif (level <= 300) return 'critical'\n\tif (level <= 400) return 'error'\n\tif (level <= 500) return 'warn'\n\tif (level <= 600) return 'notice'\n\tif (level <= 700) return 'info'\n\tif (level <= 800) return 'debug'\n\tif (level <= 900) return 'trace'\n\treturn 'planck'\n}\n\n/**\n * Convert default log level name to log level value.\n */\nexport function toLogLevel(name: string): number | undefined {\n\treturn (logLevels as any)[name.toLocaleLowerCase()]\n}\n\nexport const DEFAULT_LOG_METHOD_NAMES: string[] = [\n\t'emergency',\n\t'alert',\n\t'critical',\n\t'error',\n\t'warn',\n\t'notice',\n\t'info',\n\t'debug',\n\t'trace',\n\t'planck'\n]\n"]}
package/cjs/log_store.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logLevelStore = exports.createLogStore = void 0;
3
+ exports.createLogStore = createLogStore;
4
+ exports.logLevelStore = logLevelStore;
4
5
  var type_plus_1 = require("type-plus");
5
6
  var console_js_1 = require("./console.js");
6
7
  var log_levels_js_1 = require("./log_levels.js");
@@ -13,7 +14,6 @@ function createLogStore(options) {
13
14
  logLevelStore: logLevelStore(options)
14
15
  };
15
16
  }
16
- exports.createLogStore = createLogStore;
17
17
  function logLevelStore(options) {
18
18
  var customLevels = options.customLevels || (0, type_plus_1.record)();
19
19
  var store = {
@@ -41,5 +41,4 @@ function logLevelStore(options) {
41
41
  }
42
42
  };
43
43
  }
44
- exports.logLevelStore = logLevelStore;
45
44
  //# sourceMappingURL=log_store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"log_store.js","sourceRoot":"","sources":["../ts/log_store.ts"],"names":[],"mappings":";;;AAAA,uCAAkE;AAClE,2CAAuD;AACvD,iDAAuE;AAGvE,SAAgB,cAAc,CAC7B,OAAwC;IAExC,OAAO;QACN,OAAO,EAAE,IAAA,kBAAM,GAAE;QACjB,iBAAiB,EAAE,IAAA,kBAAM,GAAE;QAC3B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,IAAA,qCAAwB,GAAE,CAAC;QAC5D,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC;KACrC,CAAA;AACF,CAAC;AAVD,wCAUC;AAcD,SAAgB,aAAa,CAAC,OAA6B;IAC1D,IAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAA,kBAAM,GAAE,CAAA;IAErD,IAAM,KAAK,GAAG;QACb,YAAY,cAAA;QACZ,mBAAmB,EAAE,IAAA,uBAAW,EAC/B,YAAY,EACZ,UAAC,CAAC,EAAE,CAAC;YACJ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;YACtB,OAAO,CAAC,CAAA;QACT,CAAC,EACD,EAA4B,CAC5B;KACD,CAAA;IACD,OAAO;QACN,OAAO,YAAC,KAAa;;YACpB,OAAO,MAAA,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,mCAAI,IAAA,8BAAc,EAAC,KAAK,CAAC,CAAA;QACjE,CAAC;QACD,QAAQ,YAAC,IAAY;;YACpB,OAAO,MAAA,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,mCAAI,IAAA,0BAAU,EAAC,IAAI,CAAC,CAAA;QACpD,CAAC;QACD,YAAY;YACX,OAAO,IAAA,qBAAS,EACf,yBAAS,EACT,UAAC,MAAM,EAAE,IAAI;gBACZ,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK;oBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,MAAA,EAAE,KAAK,EAAE,yBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAEpF,OAAO,MAAM,CAAA;YACd,CAAC,EACD,IAAA,kBAAM,EAAC,KAAK,CAAC,YAAY,EAAE,UAAA,IAAI,IAAI,OAAA,CAAC,EAAE,IAAI,MAAA,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAA3C,CAA2C,CAAC,CAC/E,CAAA;QACF,CAAC;KACD,CAAA;AACF,CAAC;AAjCD,sCAiCC","sourcesContent":["import { mapKey, record, reduceByKey, reduceKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'\nimport type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore<N extends string = LogMethodNames>(\n\toptions: Required<StandardLogOptions<N>>\n): LogStore {\n\treturn {\n\t\tloggers: record(),\n\t\tnonConsoleLoggers: record(),\n\t\treporters: options.reporters || [createConsoleLogReporter()],\n\t\tlogLevel: options.logLevel,\n\t\tlogLevelStore: logLevelStore(options)\n\t}\n}\n\nexport interface LogStore {\n\tloggers: Record<string, Logger>\n\tnonConsoleLoggers: Record<string, Logger>\n\treporters: LogReporter[]\n\tlogLevel: LogLevel\n\tlogLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n\tcustomLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n\tconst customLevels = options.customLevels || record()\n\n\tconst store = {\n\t\tcustomLevels,\n\t\tcustomLevelsReverse: reduceByKey(\n\t\t\tcustomLevels,\n\t\t\t(p, k) => {\n\t\t\t\tp[customLevels[k]] = k\n\t\t\t\treturn p\n\t\t\t},\n\t\t\t{} as Record<number, string>\n\t\t)\n\t}\n\treturn {\n\t\tgetName(level: number) {\n\t\t\treturn store.customLevelsReverse[level] ?? toLogLevelName(level)\n\t\t},\n\t\tgetLevel(name: string) {\n\t\t\treturn store.customLevels[name] ?? toLogLevel(name)\n\t\t},\n\t\tgetAllLevels() {\n\t\t\treturn reduceKey(\n\t\t\t\tlogLevels,\n\t\t\t\t(result, name) => {\n\t\t\t\t\tif (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t\tmapKey(store.customLevels, name => ({ name, level: store.customLevels[name] }))\n\t\t\t)\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"log_store.js","sourceRoot":"","sources":["../ts/log_store.ts"],"names":[],"mappings":";;AAKA,wCAUC;AAcD,sCAiCC;AA9DD,uCAAkE;AAClE,2CAAuD;AACvD,iDAAuE;AAGvE,SAAgB,cAAc,CAC7B,OAAwC;IAExC,OAAO;QACN,OAAO,EAAE,IAAA,kBAAM,GAAE;QACjB,iBAAiB,EAAE,IAAA,kBAAM,GAAE;QAC3B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,IAAA,qCAAwB,GAAE,CAAC;QAC5D,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC;KACrC,CAAA;AACF,CAAC;AAcD,SAAgB,aAAa,CAAC,OAA6B;IAC1D,IAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAA,kBAAM,GAAE,CAAA;IAErD,IAAM,KAAK,GAAG;QACb,YAAY,cAAA;QACZ,mBAAmB,EAAE,IAAA,uBAAW,EAC/B,YAAY,EACZ,UAAC,CAAC,EAAE,CAAC;YACJ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;YACtB,OAAO,CAAC,CAAA;QACT,CAAC,EACD,EAA4B,CAC5B;KACD,CAAA;IACD,OAAO;QACN,OAAO,YAAC,KAAa;;YACpB,OAAO,MAAA,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,mCAAI,IAAA,8BAAc,EAAC,KAAK,CAAC,CAAA;QACjE,CAAC;QACD,QAAQ,YAAC,IAAY;;YACpB,OAAO,MAAA,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,mCAAI,IAAA,0BAAU,EAAC,IAAI,CAAC,CAAA;QACpD,CAAC;QACD,YAAY;YACX,OAAO,IAAA,qBAAS,EACf,yBAAS,EACT,UAAC,MAAM,EAAE,IAAI;gBACZ,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK;oBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,MAAA,EAAE,KAAK,EAAE,yBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAEpF,OAAO,MAAM,CAAA;YACd,CAAC,EACD,IAAA,kBAAM,EAAC,KAAK,CAAC,YAAY,EAAE,UAAA,IAAI,IAAI,OAAA,CAAC,EAAE,IAAI,MAAA,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAA3C,CAA2C,CAAC,CAC/E,CAAA;QACF,CAAC;KACD,CAAA;AACF,CAAC","sourcesContent":["import { mapKey, record, reduceByKey, reduceKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'\nimport type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore<N extends string = LogMethodNames>(\n\toptions: Required<StandardLogOptions<N>>\n): LogStore {\n\treturn {\n\t\tloggers: record(),\n\t\tnonConsoleLoggers: record(),\n\t\treporters: options.reporters || [createConsoleLogReporter()],\n\t\tlogLevel: options.logLevel,\n\t\tlogLevelStore: logLevelStore(options)\n\t}\n}\n\nexport interface LogStore {\n\tloggers: Record<string, Logger>\n\tnonConsoleLoggers: Record<string, Logger>\n\treporters: LogReporter[]\n\tlogLevel: LogLevel\n\tlogLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n\tcustomLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n\tconst customLevels = options.customLevels || record()\n\n\tconst store = {\n\t\tcustomLevels,\n\t\tcustomLevelsReverse: reduceByKey(\n\t\t\tcustomLevels,\n\t\t\t(p, k) => {\n\t\t\t\tp[customLevels[k]] = k\n\t\t\t\treturn p\n\t\t\t},\n\t\t\t{} as Record<number, string>\n\t\t)\n\t}\n\treturn {\n\t\tgetName(level: number) {\n\t\t\treturn store.customLevelsReverse[level] ?? toLogLevelName(level)\n\t\t},\n\t\tgetLevel(name: string) {\n\t\t\treturn store.customLevels[name] ?? toLogLevel(name)\n\t\t},\n\t\tgetAllLevels() {\n\t\t\treturn reduceKey(\n\t\t\t\tlogLevels,\n\t\t\t\t(result, name) => {\n\t\t\t\t\tif (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t\tmapKey(store.customLevels, name => ({ name, level: store.customLevels[name] }))\n\t\t\t)\n\t\t}\n\t}\n}\n"]}
package/cjs/logger.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LogStore } from './log_store.js';
1
+ import type { LogStore } from './log_store.js';
2
2
  import type { Logger, LoggerOptions, LogMethodNames } from './types.js';
3
3
  export declare function createLogger<N extends string = LogMethodNames>(store: LogStore, id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
4
4
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,EAAyB,MAAM,EAAE,aAAa,EAAE,cAAc,EAAe,MAAM,YAAY,CAAA;AAG3G,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EAC7D,KAAK,EAAE,QAAQ,EACf,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,aAAa,GACrB,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC,CA4D5B"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAGX,MAAM,EACN,aAAa,EAEb,cAAc,EAEd,MAAM,YAAY,CAAA;AAEnB,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EAC7D,KAAK,EAAE,QAAQ,EACf,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,aAAa,GACrB,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC,CA4D5B"}
package/cjs/logger.js CHANGED
@@ -9,7 +9,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9
9
  return to.concat(ar || Array.prototype.slice.call(from));
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createLogger = void 0;
12
+ exports.createLogger = createLogger;
13
13
  var log_levels_js_1 = require("./log_levels.js");
14
14
  function createLogger(store, id, options) {
15
15
  var _a;
@@ -80,7 +80,6 @@ function createLogger(store, id, options) {
80
80
  });
81
81
  return logger;
82
82
  }
83
- exports.createLogger = createLogger;
84
83
  function sanitizeId(id) {
85
84
  return id.replace(/[`~!#$%^&*()=+[\]{},|<>?]/g, '-');
86
85
  }
package/cjs/logger.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA2C;AAK3C,SAAgB,YAAY,CAC3B,KAAe,EACf,EAAU,EACV,OAAuB;;IAEvB,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;IACnB,IAAM,OAAO,GAAG,MAAA,OAAO,aAAP,OAAO,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,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;oBAAE,KAAK,CAAC,EAAE,EAAE,IAAA,EAAE,KAAK,OAAA,EAAE,IAAI,MAAA,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;YAC7F,CAAC;SACD,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACd,CAAC;AAhED,oCAgEC;AAED,SAAS,UAAU,CAAC,EAAU;IAC7B,OAAO,EAAE,CAAC,OAAO,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAA;AACrD,CAAC;AAED,SAAS,gBAAgB,CACxB,SAAwB,EACxB,QAAkB,EAClB,MAAuC;IAEvC,SAAS,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAZ,CAAY,CAAC,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,CAAC,QAAS,CAAC,EAAlB,CAAkB,CAAC,CAAA;AACrE,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAe,EAAE,WAAqB,EAAE,WAAiC;IAC3F,OAAO,WAAW,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;AACjF,CAAC","sourcesContent":["import { logLevels } from './log_levels.js'\nimport { LogStore } from './log_store.js'\nimport type { 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","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":";;;;;;;;;;;AAYA,oCAgEC;AA5ED,iDAA2C;AAY3C,SAAgB,YAAY,CAC3B,KAAe,EACf,EAAU,EACV,OAAuB;;IAEvB,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;IACnB,IAAM,OAAO,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC,CAAA;IAC1C,IAAA,KACL,OAAO,OAAO,KAAK,QAAQ;QAC1B,CAAC,CAAC,CAAC,UAAA,EAAE,IAAI,OAAA,EAAE,KAAK,OAAO,EAAd,CAAc,EAAE,KAAK,CAAC,SAAS,CAAC;QACzC,CAAC,CAAC,OAAO,YAAY,MAAM;YAC1B,CAAC,CAAC,CAAC,UAAA,EAAE,IAAI,OAAA,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAhB,CAAgB,EAAE,KAAK,CAAC,SAAS,CAAC;YAC3C,CAAC,CAAC,OAAO,OAAO,KAAK,UAAU;gBAC9B,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;gBAC5B,CAAC,CAAC,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,EAAE,CAAC,OAAO,CAAC,CAAC,EAPtB,MAAM,QAAA,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S,CAAC,EAAlB,CAAkB,CAAC,CAAA;AACrE,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAe,EAAE,WAAqB,EAAE,WAAiC;IAC3F,OAAO,WAAW,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;AACjF,CAAC","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"]}
@@ -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,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AED,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAEjG;AA6CD,wBAAgB,kCAAkC,CACjD,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GACpC,iBAAiB,CAMnB"}
package/cjs/memory.js CHANGED
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMemoryWithConsoleLogReporter = exports.createMemoryLogReporter = exports.toMessageWithLevel = void 0;
3
+ exports.toMessageWithLevel = toMessageWithLevel;
4
+ exports.createMemoryLogReporter = createMemoryLogReporter;
5
+ exports.createMemoryWithConsoleLogReporter = createMemoryWithConsoleLogReporter;
4
6
  var type_plus_1 = require("type-plus");
5
- var platform_js_1 = require("./platform.js");
6
- var formatter_js_1 = require("./formatter.js");
7
7
  var console_js_1 = require("./console.js");
8
+ var formatter_js_1 = require("./formatter.js");
9
+ var platform_js_1 = require("./platform.js");
8
10
  function toMessageWithLevel(logs) {
9
11
  return (logs
10
12
  .map(platform_js_1.toInspectLogEntry)
@@ -15,11 +17,9 @@ function toMessageWithLevel(logs) {
15
17
  // and remove this log to simplify testing.
16
18
  .replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, ''));
17
19
  }
18
- exports.toMessageWithLevel = toMessageWithLevel;
19
20
  function createMemoryLogReporter(options) {
20
21
  return Object.freeze(buildMemoryReporter((0, type_plus_1.unpartial)({ id: 'memory' }, options)));
21
22
  }
22
- exports.createMemoryLogReporter = createMemoryLogReporter;
23
23
  function buildMemoryReporter(options) {
24
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
25
  var logs = [];
@@ -44,9 +44,7 @@ function buildMemoryReporter(options) {
44
44
  return logs.map(platform_js_1.toInspectLogEntry).map(function (log) { return log.args.join(' '); });
45
45
  },
46
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(' ')); });
47
+ return logs.map(platform_js_1.toInspectLogEntry).map(function (log) { return "".concat((0, formatter_js_1.formatLogLevel)(log.level), " ").concat(log.args.join(' ')); });
50
48
  },
51
49
  getLogMessagesWithIdAndLevel: function () {
52
50
  return logs
@@ -70,5 +68,4 @@ function createMemoryWithConsoleLogReporter(options) {
70
68
  isConsoleReporter: true
71
69
  }));
72
70
  }
73
- exports.createMemoryWithConsoleLogReporter = createMemoryWithConsoleLogReporter;
74
71
  //# 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":";;;AAAA,uCAA+C;AAC/C,6CAAiD;AACjD,+CAA+C;AAE/C,2CAAuD;AAkBvD,SAAgB,kBAAkB,CAAC,IAAgB;IAClD,OAAO,CACN,IAAI;SACF,GAAG,CAAC,+BAAiB,CAAC;SACtB,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,UAAG,IAAA,6BAAc,EAAC,GAAG,CAAC,KAAK,CAAC,cAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE,EAApD,CAAoD,CAAC;SAChE,IAAI,CAAC,IAAI,CAAC;QACX,gCAAgC;QAChC,uCAAuC;QACvC,2CAA2C;SAC1C,OAAO,CAAC,mEAAmE,EAAE,EAAE,CAAC,CAClF,CAAA;AACF,CAAC;AAXD,gDAWC;AAED,SAAgB,uBAAuB,CAAC,OAAsC;IAC7E,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;AAChF,CAAC;AAFD,0DAEC;AAED,SAAS,mBAAmB,CAAC,OAAsC;IAC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AAE,cAAI,IAAA,6BAAc,EAAC,GAAG,CAAC,KAAK,CAAC,cAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE,EAA9D,CAA8D,CAAC,CAAA;QAC7E,CAAC;QACD,sBAAsB;YACrB,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAA;QAChC,CAAC;QACD;;WAEG;QACH,IAAI;YACH,IAAM,QAAQ,GAAG,IAAA,qCAAwB,GAAE,CAAA;YAC3C,IAAI,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAjB,CAAiB,CAAC,CAAA;QACrC,CAAC;KACD,CAAA;AACF,CAAC;AAED,SAAgB,kCAAkC,CACjD,OAAsC;IAEtC,OAAO,MAAM,CAAC,MAAM,CACnB,MAAM,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","sourceRoot":"","sources":["../ts/memory.ts"],"names":[],"mappings":";;AAsBA,gDAWC;AAED,0DAEC;AA6CD,gFAQC;AA1FD,uCAA+C;AAC/C,2CAAuD;AACvD,+CAA+C;AAC/C,6CAAiD;AAmBjD,SAAgB,kBAAkB,CAAC,IAAgB;IAClD,OAAO,CACN,IAAI;SACF,GAAG,CAAC,+BAAiB,CAAC;SACtB,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,UAAG,IAAA,6BAAc,EAAC,GAAG,CAAC,KAAK,CAAC,cAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE,EAApD,CAAoD,CAAC;SAChE,IAAI,CAAC,IAAI,CAAC;QACX,gCAAgC;QAChC,uCAAuC;QACvC,2CAA2C;SAC1C,OAAO,CAAC,mEAAmE,EAAE,EAAE,CAAC,CAClF,CAAA;AACF,CAAC;AAED,SAAgB,uBAAuB,CAAC,OAAsC;IAC7E,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;AAChF,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAsC;IAC5D,IAAA,KAA4B,IAAA,oBAAQ,EAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAC,CAAW,IAAK,OAAA,CAAC,EAAD,CAAC,EAAE,EAAE,OAAO,CAAC,EAA5F,EAAE,QAAA,EAAE,SAAS,eAAA,EAAE,MAAM,YAAuE,CAAA;IACpG,IAAM,IAAI,GAAe,EAAE,CAAA;IAC3B,OAAO;QACN,EAAE,IA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AA,qCAAwB,GAAE,CAAA;YAC3C,IAAI,CAAC,OAAO,CAAC,UAAA,CAAC,IAAI,OAAA,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAjB,CAAiB,CAAC,CAAA;QACrC,CAAC;KACD,CAAA;AACF,CAAC;AAED,SAAgB,kCAAkC,CACjD,OAAsC;IAEtC,OAAO,MAAM,CAAC,MAAM,CACnB,MAAM,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","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"]}
@@ -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","sourceRoot":"","sources":["../ts/platform.browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,aAAM,CAAA;AAEnD,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAa,CAAA"}
@@ -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","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,iBAAiB,GAAI,GAAG,QAAQ,aAE5C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAa,CAAA"}
package/cjs/platform.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polyfill = exports.toInspectLogEntry = void 0;
4
+ var node_util_1 = require("node:util");
4
5
  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); };
6
+ var toInspectLogEntry = function (e) { return ((e.args = e.args.map(function (value) { return (typeof value === 'object' && value !== null ? (0, node_util_1.inspect)(value) : value); })), e); };
7
7
  exports.toInspectLogEntry = toInspectLogEntry;
8
8
  exports.polyfill = (0, type_plus_1.record)();
9
9
  //# 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","sourceRoot":"","sources":["../ts/platform.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,uCAAkC;AAG3B,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,mBAAO,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 { 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"]}
@@ -1,5 +1,5 @@
1
1
  import { type LogStore } from './log_store.js';
2
- import type { LogMethodNames, Logger, LoggerOptions, StandardLogInstance, StandardLogOptions } from './types.js';
2
+ import type { Logger, LoggerOptions, LogMethodNames, StandardLogInstance, StandardLogOptions } from './types.js';
3
3
  export interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {
4
4
  }
5
5
  export declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
@@ -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;AAEnB,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,CAAE,SAAQ,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAAG;AAE3G,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EAClE,OAAO,CAAC,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AClE,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC7B,WAAW,CAAC,CAAC,CAAC,CAWhB;AAID,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EACzE,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC7B;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;CAAE,CAgDlD;AASD;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;AASlF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,IAAI,CAC1D,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,aAAa,KACnB,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC,CAAA;AAE/B,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,8BAE/F;AAQD,wBAAgB,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,QAqB7E"}
@@ -11,7 +11,11 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.configGlobal = exports.getLogger = exports.suppressLogs = exports.createStandardLogClosure = exports.createStandardLog = void 0;
14
+ exports.createStandardLog = createStandardLog;
15
+ exports.createStandardLogClosure = createStandardLogClosure;
16
+ exports.suppressLogs = suppressLogs;
17
+ exports.getLogger = getLogger;
18
+ exports.configGlobal = configGlobal;
15
19
  var type_plus_1 = require("type-plus");
16
20
  var log_levels_js_1 = require("./log_levels.js");
17
21
  var log_store_js_1 = require("./log_store.js");
@@ -28,7 +32,6 @@ function createStandardLog(options) {
28
32
  standard_log_ctx_js_1.ctx.gsl = closure;
29
33
  return closure.standardLog;
30
34
  }
31
- exports.createStandardLog = createStandardLog;
32
35
  function noop() { }
33
36
  function createStandardLogClosure(options) {
34
37
  var _a, _b, _c;
@@ -75,7 +78,6 @@ function createStandardLogClosure(options) {
75
78
  }
76
79
  };
77
80
  }
78
- exports.createStandardLogClosure = createStandardLogClosure;
79
81
  function createDummyLogger(logMethods) {
80
82
  return logMethods.reduce(function (p, m) {
81
83
  p[m] = noop;
@@ -93,11 +95,9 @@ function suppressLogs(block) {
93
95
  logs.forEach(function (l, i) { return (l.level = origLevels[i]); });
94
96
  return result;
95
97
  }
96
- exports.suppressLogs = suppressLogs;
97
98
  function getLogger(id, options) {
98
99
  return getGlobalSL().getLogger(id, options);
99
100
  }
100
- exports.getLogger = getLogger;
101
101
  function getGlobalSL() {
102
102
  if (!standard_log_ctx_js_1.ctx.gsl)
103
103
  standard_log_ctx_js_1.ctx.gsl = createStandardLogClosure();
@@ -123,5 +123,4 @@ function configGlobal(options) {
123
123
  }
124
124
  standard_log_ctx_js_1.ctx.configured = true;
125
125
  }
126
- exports.configGlobal = configGlobal;
127
126
  //# sourceMappingURL=standard_log.js.map