standard-log 11.5.2 → 12.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 (109) hide show
  1. package/README.md +2 -3
  2. package/cjs/console.js +4 -4
  3. package/cjs/console.js.map +1 -1
  4. package/cjs/formatter.js +2 -2
  5. package/cjs/formatter.js.map +1 -1
  6. package/cjs/index.d.ts +4 -4
  7. package/cjs/index.d.ts.map +1 -1
  8. package/cjs/index.js +7 -8
  9. package/cjs/index.js.map +1 -1
  10. package/cjs/{logLevels.d.ts → log_levels.d.ts} +1 -1
  11. package/cjs/log_levels.d.ts.map +1 -0
  12. package/cjs/{logLevels.js → log_levels.js} +1 -1
  13. package/{esm/logLevels.js.map → cjs/log_levels.js.map} +1 -1
  14. package/{esm/logStore.d.ts → cjs/log_store.d.ts} +1 -1
  15. package/cjs/log_store.d.ts.map +1 -0
  16. package/cjs/{logStore.js → log_store.js} +6 -6
  17. package/cjs/log_store.js.map +1 -0
  18. package/cjs/logger.d.ts +1 -1
  19. package/cjs/logger.d.ts.map +1 -1
  20. package/cjs/logger.js +3 -3
  21. package/cjs/logger.js.map +1 -1
  22. package/cjs/{standardLog.ctx.d.ts → standard_log.ctx.d.ts} +2 -2
  23. package/cjs/standard_log.ctx.d.ts.map +1 -0
  24. package/cjs/{standardLog.ctx.js → standard_log.ctx.js} +1 -1
  25. package/cjs/standard_log.ctx.js.map +1 -0
  26. package/{esm/standardLog.d.ts → cjs/standard_log.d.ts} +3 -8
  27. package/cjs/standard_log.d.ts.map +1 -0
  28. package/cjs/{standardLog.js → standard_log.js} +20 -28
  29. package/cjs/standard_log.js.map +1 -0
  30. package/cjs/standard_log.mocks.d.ts +8 -0
  31. package/cjs/standard_log.mocks.d.ts.map +1 -0
  32. package/cjs/standard_log.mocks.js +32 -0
  33. package/cjs/standard_log.mocks.js.map +1 -0
  34. package/cjs/testing/index.d.ts +2 -0
  35. package/cjs/testing/index.d.ts.map +1 -0
  36. package/cjs/testing/index.js +6 -0
  37. package/cjs/testing/index.js.map +1 -0
  38. package/dist/standard-log.es5.js +56 -65
  39. package/dist/standard-log.es5.js.gz +0 -0
  40. package/dist/standard-log.es5.js.map +1 -1
  41. package/dist/standard-log.es5.js.map.gz +0 -0
  42. package/dist/standard-log.esm.js +58 -67
  43. package/dist/standard-log.esm.js.gz +0 -0
  44. package/dist/standard-log.esm.js.map +1 -1
  45. package/dist/standard-log.esm.js.map.gz +0 -0
  46. package/esm/console.js +1 -1
  47. package/esm/console.js.map +1 -1
  48. package/esm/formatter.js +1 -1
  49. package/esm/formatter.js.map +1 -1
  50. package/esm/index.d.ts +4 -4
  51. package/esm/index.d.ts.map +1 -1
  52. package/esm/index.js +2 -2
  53. package/esm/index.js.map +1 -1
  54. package/esm/{logLevels.d.ts → log_levels.d.ts} +1 -1
  55. package/esm/log_levels.d.ts.map +1 -0
  56. package/esm/{logLevels.js → log_levels.js} +1 -1
  57. package/esm/log_levels.js.map +1 -0
  58. package/{cjs/logStore.d.ts → esm/log_store.d.ts} +1 -1
  59. package/esm/log_store.d.ts.map +1 -0
  60. package/esm/{logStore.js → log_store.js} +2 -2
  61. package/esm/log_store.js.map +1 -0
  62. package/esm/logger.d.ts +1 -1
  63. package/esm/logger.d.ts.map +1 -1
  64. package/esm/logger.js +1 -1
  65. package/esm/logger.js.map +1 -1
  66. package/esm/{standardLog.ctx.d.ts → standard_log.ctx.d.ts} +2 -2
  67. package/esm/standard_log.ctx.d.ts.map +1 -0
  68. package/esm/{standardLog.ctx.js → standard_log.ctx.js} +1 -1
  69. package/esm/standard_log.ctx.js.map +1 -0
  70. package/{cjs/standardLog.d.ts → esm/standard_log.d.ts} +3 -8
  71. package/esm/standard_log.d.ts.map +1 -0
  72. package/esm/{standardLog.js → standard_log.js} +4 -10
  73. package/esm/standard_log.js.map +1 -0
  74. package/esm/standard_log.mocks.d.ts +8 -0
  75. package/esm/standard_log.mocks.d.ts.map +1 -0
  76. package/esm/standard_log.mocks.js +16 -0
  77. package/esm/standard_log.mocks.js.map +1 -0
  78. package/esm/testing/index.d.ts +2 -0
  79. package/esm/testing/index.d.ts.map +1 -0
  80. package/esm/testing/index.js +2 -0
  81. package/esm/testing/index.js.map +1 -0
  82. package/package.json +8 -7
  83. package/testing/index.d.ts +1 -0
  84. package/testing/index.js +1 -0
  85. package/ts/console.ts +1 -1
  86. package/ts/formatter.ts +1 -1
  87. package/ts/index.ts +5 -11
  88. package/ts/{logStore.ts → log_store.ts} +1 -1
  89. package/ts/logger.ts +2 -2
  90. package/ts/{standardLog.ctx.ts → standard_log.ctx.ts} +1 -1
  91. package/ts/standard_log.mocks.ts +22 -0
  92. package/ts/{standardLog.ts → standard_log.ts} +4 -18
  93. package/ts/testing/index.ts +1 -0
  94. package/cjs/logLevels.d.ts.map +0 -1
  95. package/cjs/logLevels.js.map +0 -1
  96. package/cjs/logStore.d.ts.map +0 -1
  97. package/cjs/logStore.js.map +0 -1
  98. package/cjs/standardLog.ctx.d.ts.map +0 -1
  99. package/cjs/standardLog.ctx.js.map +0 -1
  100. package/cjs/standardLog.d.ts.map +0 -1
  101. package/cjs/standardLog.js.map +0 -1
  102. package/esm/logLevels.d.ts.map +0 -1
  103. package/esm/logStore.d.ts.map +0 -1
  104. package/esm/logStore.js.map +0 -1
  105. package/esm/standardLog.ctx.d.ts.map +0 -1
  106. package/esm/standardLog.ctx.js.map +0 -1
  107. package/esm/standardLog.d.ts.map +0 -1
  108. package/esm/standardLog.js.map +0 -1
  109. /package/ts/{logLevels.ts → log_levels.ts} +0 -0
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][rendering-example]
51
+ ![Rendering example](https://raw.githubusercontent.com/unional/standard-log/main/images/color-log.png)
52
52
 
53
53
  (above is logged with `standard-log-color`)
54
54
 
@@ -149,7 +149,7 @@ During test,
149
149
  you should use `createStandardLogForTest` which includes a `MemoryReporter` to capture the logs.
150
150
 
151
151
  ```ts
152
- import { createStandardLogForTest, createMemoryReporter } from 'standard-log'
152
+ import { createStandardLogForTest } from 'standard-log/testing'
153
153
 
154
154
  test('your test', () => {
155
155
  const standardLog = createStandardLogForTest()
@@ -198,7 +198,6 @@ It is the main driving force for 9.0.
198
198
  [github-nodejs]: https://github.com/unional/standard-log/workflows/release/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
- [rendering-example]: https://github.com/unional/standard-log/tree/main/images/color-log.png
202
201
  [standard-log-color]: https://github.com/unional/standard-log/tree/master/packages/color
203
202
  [standard-log-syslog]: https://github.com/unional/standard-log/tree/master/packages/syslog
204
203
  [standard-log]: https://github.com/unional/standard-log
package/cjs/console.js CHANGED
@@ -3,18 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createConsoleLogReporter = exports.toConsoleMethod = void 0;
4
4
  var type_plus_1 = require("type-plus");
5
5
  var formatter_js_1 = require("./formatter.js");
6
- var logLevels_js_1 = require("./logLevels.js");
6
+ var log_levels_js_1 = require("./log_levels.js");
7
7
  var platform_js_1 = require("./platform.js");
8
8
  function toConsoleMethod(level) {
9
9
  switch (true) {
10
10
  // edge case in case none is somehow written
11
11
  case level <= 0:
12
12
  return 'debug';
13
- case level <= logLevels_js_1.logLevels.error:
13
+ case level <= log_levels_js_1.logLevels.error:
14
14
  return 'error';
15
- case level <= logLevels_js_1.logLevels.warn:
15
+ case level <= log_levels_js_1.logLevels.warn:
16
16
  return 'warn';
17
- case level <= logLevels_js_1.logLevels.info:
17
+ case level <= log_levels_js_1.logLevels.info:
18
18
  return 'info';
19
19
  default:
20
20
  return 'debug';
@@ -1 +1 @@
1
- {"version":3,"file":"console.js","sourceRoot":"","sources":["../ts/console.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,+CAAiD;AACjD,+CAA0C;AAC1C,6CAAwC;AAGxC,SAAg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AO,MAAM,CAAA;QACd,CAAC;QACD,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 './logLevels.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":";;;AAAA,uCAAqC;AACrC,+CAAiD;AACjD,iDAA2C;AAC3C,6CAAwC;AAGxC,SAAgB,eAAe,CAAC,KAAa;IAC5C,QAAQ,IAAI,EAAE;QACb,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,CAAC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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;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"]}
package/cjs/formatter.js CHANGED
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.consoleFormatter = exports.plainLogFormatter = exports.formatLogLevel = exports.createTimestampFormatter = void 0;
16
16
  var ms_1 = __importDefault(require("ms"));
17
17
  var upper_case_1 = require("upper-case");
18
- var logLevels_js_1 = require("./logLevels.js");
18
+ var log_levels_js_1 = require("./log_levels.js");
19
19
  function createTimestampFormatter(format) {
20
20
  switch (format) {
21
21
  case 'none':
@@ -35,7 +35,7 @@ function createTimestampFormatter(format) {
35
35
  }
36
36
  exports.createTimestampFormatter = createTimestampFormatter;
37
37
  function formatLogLevel(level) {
38
- return "(".concat((0, upper_case_1.upperCase)((0, logLevels_js_1.toLogLevelName)(level)), ")");
38
+ return "(".concat((0, upper_case_1.upperCase)((0, log_levels_js_1.toLogLevelName)(level)), ")");
39
39
  }
40
40
  exports.formatLogLevel = formatLogL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tC,OAAO,IAAI,CAAA;AACZ,CAAC;AAFD,4CAEC","sourcesContent":["import ms from 'ms'\nimport { upperCase } from 'upper-case'\nimport { toLogLevelName } from './logLevels.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":";;;;;;;;;;;;;;;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"]}
package/cjs/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export * from './console.js';
2
2
  export * from './errors.js';
3
3
  export * from './formatter.js';
4
- export * from './logLevels.js';
4
+ export * from './log_levels.js';
5
5
  export * from './memory.js';
6
- export { configGlobal, createStandardLog, createStandardLogForTest, getLogger, suppressLogs } from './standardLog.js';
7
- export type { GetLogger, StandardLog, StandardLogForTest } from './standardLog.js';
8
- export type { ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, Logger, LoggerOptions, LogLevel, LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, ReporterFilter, StandardLogInstance, StandardLogOptions } from './types.js';
6
+ export { configGlobal, createStandardLog, getLogger, suppressLogs } from './standard_log.js';
7
+ 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';
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,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,OAAO,EACN,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,SAAS,EACT,YAAY,EACZ,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAClF,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"}
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"}
package/cjs/index.js CHANGED
@@ -14,16 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.suppressLogs = exports.getLogger = exports.createStandardLogForTest = exports.createStandardLog = exports.configGlobal = void 0;
17
+ exports.suppressLogs = exports.getLogger = exports.createStandardLog = exports.configGlobal = void 0;
18
18
  __exportStar(require("./console.js"), exports);
19
19
  __exportStar(require("./errors.js"), exports);
20
20
  __exportStar(require("./formatter.js"), exports);
21
- __exportStar(require("./logLevels.js"), exports);
21
+ __exportStar(require("./log_levels.js"), exports);
22
22
  __exportStar(require("./memory.js"), exports);
23
- var standardLog_js_1 = require("./standardLog.js");
24
- Object.defineProperty(exports, "configGlobal", { enumerable: true, get: function () { return standardLog_js_1.configGlobal; } });
25
- Object.defineProperty(exports, "createStandardLog", { enumerable: true, get: function () { return standardLog_js_1.createStandardLog; } });
26
- Object.defineProperty(exports, "createStandardLogForTest", { enumerable: true, get: function () { return standardLog_js_1.createStandardLogForTest; } });
27
- Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return standardLog_js_1.getLogger; } });
28
- Object.defineProperty(exports, "suppressLogs", { enumerable: true, get: function () { return standardLog_js_1.suppressLogs; } });
23
+ var standard_log_js_1 = require("./standard_log.js");
24
+ Object.defineProperty(exports, "configGlobal", { enumerable: true, get: function () { return standard_log_js_1.configGlobal; } });
25
+ Object.defineProperty(exports, "createStandardLog", { enumerable: true, get: function () { return standard_log_js_1.createStandardLog; } });
26
+ Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return standard_log_js_1.getLogger; } });
27
+ Object.defineProperty(exports, "suppressLogs", { enumerable: true, get: function () { return standard_log_js_1.suppressLogs; } });
29
28
  //# sourceMappingURL=index.js.map
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,iDAA8B;AAC9B,8CAA2B;AAC3B,mDAMyB;AALxB,8GAAA,YAAY,OAAA;AACZ,mHAAA,iBAAiB,OAAA;AACjB,0HAAA,wBAAwB,OAAA;AACxB,2GAAA,SAAS,OAAA;AACT,8GAAA,YAAY,OAAA","sourcesContent":["export * from './console.js'\nexport * from './errors.js'\nexport * from './formatter.js'\nexport * from './logLevels.js'\nexport * from './memory.js'\nexport {\n\tconfigGlobal,\n\tcreateStandardLog,\n\tcreateStandardLogForTest,\n\tgetLogger,\n\tsuppressLogs\n} from './standardLog.js'\nexport type { GetLogger, StandardLog, StandardLogForTest } from './standardLog.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"]}
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"]}
@@ -78,4 +78,4 @@ export declare function toLogLevelName(level: number): "emergency" | "alert" | "
78
78
  */
79
79
  export declare function toLogLevel(name: string): number | undefined;
80
80
  export declare const DEFAULT_LOG_METHOD_NAMES: string[];
81
- //# sourceMappingURL=logLevels.d.ts.map
81
+ //# sourceMappingURL=log_levels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log_levels.d.ts","sourceRoot":"","sources":["../ts/log_levels.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;IACrB;;OAEG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;OAEG;;CAEH,CAAA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,4GAW3C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE3D;AAED,eAAO,MAAM,wBAAwB,EAAE,MAAM,EAW5C,CAAA"}
@@ -116,4 +116,4 @@ exports.DEFAULT_LOG_METHOD_NAMES = [
116
116
  'trace',
117
117
  'planck'
118
118
  ];
119
- //# sourceMappingURL=logLevels.js.map
119
+ //# sourceMappingURL=log_levels.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logLevels.js","sourceRoot":"","sources":["../ts/logLevels.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,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,MAAM,UAAU,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,MAAM,UAAU,UAAU,CAAC,IAAY;IACtC,OAAQ,SAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAA;AACpD,CAAC;AAED,MAAM,CAAC,MAAM,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":";;;AAAa,QA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;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"]}
@@ -18,4 +18,4 @@ export declare function logLevelStore(options: LogLevelStoreOptions): {
18
18
  level: number;
19
19
  }[];
20
20
  };
21
- //# sourceMappingURL=logStore.d.ts.map
21
+ //# sourceMappingURL=log_store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log_store.d.ts","sourceRoot":"","sources":["../ts/log_store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEnG,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EAC/D,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GACtC,QAAQ,CAQV;AAED,MAAM,WAAW,QAAQ;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,SAAS,EAAE,WAAW,EAAE,CAAA;IACxB,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;CAC/C;AAED,MAAM,WAAW,oBAAoB;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;mBAe1C,MAAM;mBAGN,MAAM;;;;;EAetB"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logLevelStore = exports.createLogStore = void 0;
4
4
  var type_plus_1 = require("type-plus");
5
5
  var console_js_1 = require("./console.js");
6
- var logLevels_js_1 = require("./logLevels.js");
6
+ var log_levels_js_1 = require("./log_levels.js");
7
7
  function createLogStore(options) {
8
8
  return {
9
9
  loggers: (0, type_plus_1.record)(),
@@ -26,20 +26,20 @@ function logLevelStore(options) {
26
26
  return {
27
27
  getName: function (level) {
28
28
  var _a;
29
- return (_a = store.customLevelsReverse[level]) !== null && _a !== void 0 ? _a : (0, logLevels_js_1.toLogLevelName)(level);
29
+ return (_a = store.customLevelsReverse[level]) !== null && _a !== void 0 ? _a : (0, log_levels_js_1.toLogLevelName)(level);
30
30
  },
31
31
  getLevel: function (name) {
32
32
  var _a;
33
- return (_a = store.customLevels[name]) !== null && _a !== void 0 ? _a : (0, logLevels_js_1.toLogLevel)(name);
33
+ return (_a = store.customLevels[name]) !== null && _a !== void 0 ? _a : (0, log_levels_js_1.toLogLevel)(name);
34
34
  },
35
35
  getAllLevels: function () {
36
- return (0, type_plus_1.reduceKey)(logLevels_js_1.logLevels, function (result, name) {
36
+ return (0, type_plus_1.reduceKey)(log_levels_js_1.logLevels, function (result, name) {
37
37
  if (name !== 'none' && name !== 'all')
38
- result.push({ name: name, level: logLevels_js_1.logLevels[name] });
38
+ result.push({ name: name, level: log_levels_js_1.logLevels[name] });
39
39
  return result;
40
40
  }, (0, type_plus_1.mapKey)(store.customLevels, function (name) { return ({ name: name, level: store.customLevels[name] }); }));
41
41
  }
42
42
  };
43
43
  }
44
44
  exports.logLevelStore = logLevelStore;
45
- //# sourceMappingURL=logStore.js.map
45
+ //# sourceMappingURL=log_store.js.map
@@ -0,0 +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;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K,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"]}
package/cjs/logger.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LogStore } from './logStore.js';
1
+ import { 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,eAAe,CAAA;AACxC,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,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"}
package/cjs/logger.js CHANGED
@@ -10,7 +10,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.createLogger = void 0;
13
- var logLevels_js_1 = require("./logLevels.js");
13
+ var log_levels_js_1 = require("./log_levels.js");
14
14
  function createLogger(store, id, options) {
15
15
  var _a;
16
16
  id = sanitizeId(id);
@@ -39,10 +39,10 @@ function createLogger(store, id, options) {
39
39
  for (var _i = 0; _i < arguments.length; _i++) {
40
40
  args[_i] = arguments[_i];
41
41
  }
42
- if (shouldLog(store, logLevels_js_1.logLevels.debug, logger.level))
42
+ if (shouldLog(store, log_levels_js_1.logLevels.debug, logger.level))
43
43
  write({
44
44
  id: id,
45
- level: logLevels_js_1.logLevels.debug,
45
+ level: log_levels_js_1.logLevels.debug,
46
46
  args: __spreadArray([++counter], args, true),
47
47
  timestamp: new Date()
48
48
  });
package/cjs/logger.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../ts/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA0C;AAK1C,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;YAC3B,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;gBAC/B,CAAC,CAAC,CAAC,OAA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AAC,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 './logLevels.js'\nimport { LogStore } from './logStore.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[]) => {\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":";;;;;;;;;;;;AAAA,iDAA2C;AAK3C,SAAgB,YAAY,CAC3B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E,KAAK;YACf,KAAK,EAAE;gBAAC,cAAc;qBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;oBAAd,yBAAc;;gBACrB,IAAI,SAAS,CAAC,KAAK,EAAE,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[]) => {\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,4 +1,4 @@
1
- import type { LogStore } from './logStore.js';
1
+ import type { LogStore } from './log_store.js';
2
2
  import type { LogMethodNames, StandardLogInstance } from './types.js';
3
3
  export declare const ctx: {
4
4
  configured?: boolean;
@@ -7,4 +7,4 @@ export declare const ctx: {
7
7
  standardLog: StandardLogInstance<LogMethodNames>;
8
8
  };
9
9
  };
10
- //# sourceMappingURL=standardLog.ctx.d.ts.map
10
+ //# sourceMappingURL=standard_log.ctx.d.ts.map
@@ -0,0 +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"}
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ctx = void 0;
4
4
  var type_plus_1 = require("type-plus");
5
5
  exports.ctx = (0, type_plus_1.record)();
6
- //# sourceMappingURL=standardLog.ctx.js.map
6
+ //# sourceMappingURL=standard_log.ctx.js.map
@@ -0,0 +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,6 +1,5 @@
1
- import { LogStore } from './logStore.js';
2
- import { MemoryLogReporter } from './memory.js';
3
- import type { Logger, LoggerOptions, LogLevel, LogMethodNames, StandardLogInstance, StandardLogOptions } from './types.js';
1
+ import { type LogStore } from './log_store.js';
2
+ import type { LogMethodNames, Logger, LoggerOptions, StandardLogInstance, StandardLogOptions } from './types.js';
4
3
  export interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {
5
4
  }
6
5
  export declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
@@ -8,10 +7,6 @@ export declare function createStandardLogClosure<N extends string = LogMethodNam
8
7
  store: LogStore;
9
8
  standardLog: StandardLog<N>;
10
9
  };
11
- export type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
12
- reporter: MemoryLogReporter;
13
- };
14
- export declare function createStandardLogForTest<N extends string = LogMethodNames>(logLevel?: LogLevel): StandardLogForTest<N>;
15
10
  /**
16
11
  * Suppress logging within the code block.
17
12
  */
@@ -19,4 +14,4 @@ export declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Lo
19
14
  export type GetLogger<N extends string = LogMethodNames> = (id: string, options?: LoggerOptions) => Logger<LogMethodNames | N>;
20
15
  export declare function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions): Logger<LogMethodNames | N>;
21
16
  export declare function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>): void;
22
- //# sourceMappingURL=standardLog.d.ts.map
17
+ //# sourceMappingURL=standard_log.d.ts.map
@@ -0,0 +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,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,13 +11,12 @@ 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.createStandardLogForTest = exports.createStandardLogClosure = exports.createStandardLog = void 0;
14
+ exports.configGlobal = exports.getLogger = exports.suppressLogs = exports.createStandardLogClosure = exports.createStandardLog = void 0;
15
15
  var type_plus_1 = require("type-plus");
16
+ var log_levels_js_1 = require("./log_levels.js");
17
+ var log_store_js_1 = require("./log_store.js");
16
18
  var logger_js_1 = require("./logger.js");
17
- var logLevels_js_1 = require("./logLevels.js");
18
- var logStore_js_1 = require("./logStore.js");
19
- var memory_js_1 = require("./memory.js");
20
- var standardLog_ctx_js_1 = require("./standardLog.ctx.js");
19
+ var standard_log_ctx_js_1 = require("./standard_log.ctx.js");
21
20
  function createStandardLog(options) {
22
21
  var _a;
23
22
  var closure = createStandardLogClosure(options);
@@ -25,8 +24,8 @@ function createStandardLog(options) {
25
24
  var log = closure.standardLog.getLogger('standard-log');
26
25
  log.critical("Detected reporter with empty id. This is not allowed as it will create problems with feature like 'getNonConsoleLogger()'. Please add an id to your reporter.");
27
26
  }
28
- if (!standardLog_ctx_js_1.ctx.gsl)
29
- standardLog_ctx_js_1.ctx.gsl = closure;
27
+ if (!standard_log_ctx_js_1.ctx.gsl)
28
+ standard_log_ctx_js_1.ctx.gsl = closure;
30
29
  return closure.standardLog;
31
30
  }
32
31
  exports.createStandardLog = createStandardLog;
@@ -34,9 +33,9 @@ function noop() { }
34
33
  function createStandardLogClosure(options) {
35
34
  var _a, _b, _c;
36
35
  // TODO reporter.id must not be empty
37
- var store = (0, logStore_js_1.createLogStore)((0, type_plus_1.required)({ logLevel: logLevels_js_1.logLevels.info }, options));
36
+ var store = (0, log_store_js_1.createLogStore)((0, type_plus_1.required)({ logLevel: log_levels_js_1.logLevels.info }, options));
38
37
  var nonConsoleReporters = (_b = (_a = options === null || options === void 0 ? void 0 : options.reporters) === null || _a === void 0 ? void 0 : _a.filter(function (r) { return !r.isConsoleReporter; }).map(function (r) { return r.id; })) !== null && _b !== void 0 ? _b : [];
39
- var logMethods = logLevels_js_1.DEFAULT_LOG_METHOD_NAMES.concat(Object.keys((_c = options === null || options === void 0 ? void 0 : options.customLevels) !== null && _c !== void 0 ? _c : {})).concat([
38
+ var logMethods = log_levels_js_1.DEFAULT_LOG_METHOD_NAMES.concat(Object.keys((_c = options === null || options === void 0 ? void 0 : options.customLevels) !== null && _c !== void 0 ? _c : {})).concat([
40
39
  'on',
41
40
  'count',
42
41
  'write'
@@ -83,20 +82,13 @@ function createDummyLogger(logMethods) {
83
82
  return p;
84
83
  }, (0, type_plus_1.record)());
85
84
  }
86
- function createStandardLogForTest(logLevel) {
87
- if (logLevel === void 0) { logLevel = logLevels_js_1.logLevels.debug; }
88
- var reporter = (0, memory_js_1.createMemoryLogReporter)();
89
- var closure = createStandardLogClosure({ reporters: [reporter], logLevel: logLevel });
90
- return __assign(__assign({}, closure.standardLog), { reporter: reporter });
91
- }
92
- exports.createStandardLogForTest = createStandardLogForTest;
93
85
  function suppressLogs(block) {
94
86
  var logs = [];
95
87
  for (var _i = 1; _i < arguments.length; _i++) {
96
88
  logs[_i - 1] = arguments[_i];
97
89
  }
98
90
  var origLevels = logs.map(function (l) { return l.level; });
99
- logs.forEach(function (l) { return (l.level = logLevels_js_1.logLevels.none); });
91
+ logs.forEach(function (l) { return (l.level = log_levels_js_1.logLevels.none); });
100
92
  var result = block();
101
93
  logs.forEach(function (l, i) { return (l.level = origLevels[i]); });
102
94
  return result;
@@ -107,29 +99,29 @@ function getLogger(id, options) {
107
99
  }
108
100
  exports.getLogger = getLogger;
109
101
  function getGlobalSL() {
110
- if (!standardLog_ctx_js_1.ctx.gsl)
111
- standardLog_ctx_js_1.ctx.gsl = createStandardLogClosure();
112
- return standardLog_ctx_js_1.ctx.gsl.standardLog;
102
+ if (!standard_log_ctx_js_1.ctx.gsl)
103
+ standard_log_ctx_js_1.ctx.gsl = createStandardLogClosure();
104
+ return standard_log_ctx_js_1.ctx.gsl.standardLog;
113
105
  }
114
106
  function configGlobal(options) {
115
- if (standardLog_ctx_js_1.ctx.configured) {
116
- var log = standardLog_ctx_js_1.ctx.gsl.standardLog.getLogger('standard-log');
107
+ if (standard_log_ctx_js_1.ctx.configured) {
108
+ var log = standard_log_ctx_js_1.ctx.gsl.standardLog.getLogger('standard-log');
117
109
  log.warn('configGlobal() is being called more than once. Please make sure this is expected. Application should use `createStandardLog()` most of the time.');
118
110
  }
119
- if (standardLog_ctx_js_1.ctx.gsl) {
111
+ if (standard_log_ctx_js_1.ctx.gsl) {
120
112
  if (options.logLevel) {
121
- standardLog_ctx_js_1.ctx.gsl.store.logLevel = options.logLevel;
113
+ standard_log_ctx_js_1.ctx.gsl.store.logLevel = options.logLevel;
122
114
  }
123
115
  if (options.reporters) {
124
- var reporters = standardLog_ctx_js_1.ctx.gsl.store.reporters;
116
+ var reporters = standard_log_ctx_js_1.ctx.gsl.store.reporters;
125
117
  reporters.length = 0;
126
118
  reporters.push.apply(reporters, options.reporters);
127
119
  }
128
120
  }
129
121
  else {
130
- standardLog_ctx_js_1.ctx.gsl = createStandardLogClosure(options);
122
+ standard_log_ctx_js_1.ctx.gsl = createStandardLogClosure(options);
131
123
  }
132
- standardLog_ctx_js_1.ctx.configured = true;
124
+ standard_log_ctx_js_1.ctx.configured = true;
133
125
  }
134
126
  exports.configGlobal = configGlobal;
135
- //# sourceMappingURL=standardLog.js.map
127
+ //# sourceMappingURL=stand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CAAyB,CAAC,CAAA;IACjD,OAAO,MAAM,CAAA;AACd,CAAC;AAND,oCAMC;AAOD,SAAgB,SAAS,CAAoC,EAAU,EAAE,OAAuB;IAC/F,OAAO,WAAW,EAAK,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;AAC/C,CAAC;AAFD,8BAEC;AAED,SAAS,WAAW;IACnB,IAAI,CAAC,yBAAG,CAAC,GAAG;QAAE,yBAAG,CAAC,GAAG,GAAG,wBAAwB,EAAE,CAAA;IAElD,OAAO,yBAAG,CAAC,GAAI,CAAC,WAAqC,CAAA;AACtD,CAAC;AAED,SAAgB,YAAY,CAAC,OAAiD;IAC7E,IAAI,yBAAG,CAAC,UAAU,EAAE;QACnB,IAAM,GAAG,GAAG,yBAAG,CAAC,GAAI,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;QAC1D,GAAG,CAAC,IAAI,CACP,kJAAkJ,CAClJ,CAAA;KACD;IAED,IAAI,yBAAG,CAAC,GAAG,EAAE;QACZ,IAAI,OAAO,CAAC,QAAQ,EAAE;YACrB,yBAAG,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;SACzC;QACD,IAAI,OAAO,CAAC,SAAS,EAAE;YACtB,IAAM,SAAS,GAAG,yBAAG,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAA;YACzC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;YACpB,SAAS,CAAC,IAAI,OAAd,SAAS,EAAS,OAAO,CAAC,SAAS,EAAC;SACpC;KACD;SAAM;QACN,yBAAG,CAAC,GAAG,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAA;KAC3C;IACD,yBAAG,CAAC,UAAU,GAAG,IAAI,CAAA;AACtB,CAAC;AArBD,oCAqBC","sourcesContent":["import { record, required } from 'type-plus'\nimport { DEFAULT_LOG_METHOD_NAMES, logLevels } from './log_levels.js'\nimport { createLogStore, type LogStore } from './log_store.js'\nimport { createLogger } from './logger.js'\nimport { ctx } from './standard_log.ctx.js'\nimport type {\n\tLogMethodNames,\n\tLogger,\n\tLoggerOptions,\n\tStandardLogInstance,\n\tStandardLogOptions\n} from './types.js'\n\nexport interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {}\n\nexport function createStandardLog<N extends string = LogMethodNames>(\n\toptions?: StandardLogOptions<N>\n): StandardLog<N> {\n\tconst closure = createStandardLogClosure(options)\n\tif (options?.reporters?.some(r => !r.id)) {\n\t\tconst log = closure.standardLog.getLogger('standard-log')\n\t\tlog.critical(\n\t\t\t`Detected reporter with empty id. This is not allowed as it will create problems with feature like 'getNonConsoleLogger()'. Please add an id to your reporter.`\n\t\t)\n\t}\n\n\tif (!ctx.gsl) ctx.gsl = closure as any\n\treturn closure.standardLog\n}\n\nfunction noop() {}\n\nexport function createStandardLogClosure<N extends string = LogMethodNames>(\n\toptions?: StandardLogOptions<N>\n): { store: LogStore; standardLog: StandardLog<N> } {\n\t// TODO reporter.id must not be empty\n\tconst store = createLogStore(required({ logLevel: logLevels.info }, options))\n\tconst nonConsoleReporters = options?.reporters?.filter(r => !r.isConsoleReporter).map(r => r.id) ?? []\n\tconst logMethods = DEFAULT_LOG_METHOD_NAMES.concat(Object.keys(options?.customLevels ?? {})).concat([\n\t\t'on',\n\t\t'count',\n\t\t'write'\n\t])\n\treturn {\n\t\tstore,\n\t\tstandardLog: {\n\t\t\tget logLevel() {\n\t\t\t\treturn store.logLevel\n\t\t\t},\n\n\t\t\ttoLogLevelName(level: number) {\n\t\t\t\treturn store.logLevelStore.getName(level)\n\t\t\t},\n\t\t\ttoLogLevel(name: string) {\n\t\t\t\treturn store.logLevelStore.getLevel(name)\n\t\t\t},\n\t\t\tgetLogger(id: string, options?: LoggerOptions) {\n\t\t\t\tif (store.loggers[id]) return store.loggers[id] as any\n\t\t\t\treturn (store.loggers[id] = createLogger(store, id, { ssf: this.getLogger, ...options }) as any)\n\t\t\t},\n\t\t\tgetNonConsoleLogger(id, options?) {\n\t\t\t\tif (store.nonConsoleLoggers[id]) return store.nonConsoleLoggers[id] as any\n\n\t\t\t\tif (store.loggers[id]) {\n\t\t\t\t\tconst log = this.getLogger('standard-log')\n\t\t\t\t\tlog.warn(`attempt to create a non-console logger with existing id ('${id}'), ignoring`)\n\t\t\t\t\treturn (store.nonConsoleLoggers[id] = createDummyLogger(logMethods))\n\t\t\t\t}\n\n\t\t\t\treturn (store.nonConsoleLoggers[id] =\n\t\t\t\t\tnonConsoleReporters.length === 0\n\t\t\t\t\t\t? createDummyLogger(logMethods)\n\t\t\t\t\t\t: createLogger(store, id, {\n\t\t\t\t\t\t\t\tssf: this.getNonConsoleLogger,\n\t\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t\t\twriteTo(reporterId) {\n\t\t\t\t\t\t\t\t\treturn nonConsoleReporters.indexOf(reporterId) >= 0\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t }))\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction createDummyLogger(logMethods: string[]) {\n\treturn logMethods.reduce((p, m) => {\n\t\tp[m] = noop\n\t\treturn p\n\t}, record()) as Logger\n}\n\n/**\n * Suppress logging within the code block.\n */\nexport function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R\nexport function suppressLogs<R>(block: () => R, ...logs: Logger[]): R {\n\tconst origLevels = logs.map(l => l.level)\n\tlogs.forEach(l => (l.level = logLevels.none))\n\tconst result = block()\n\tlogs.forEach((l, i) => (l.level = origLevels[i]))\n\treturn result\n}\n\nexport type GetLogger<N extends string = LogMethodNames> = (\n\tid: string,\n\toptions?: LoggerOptions\n) => Logger<LogMethodNames | N>\n\nexport function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions) {\n\treturn getGlobalSL<N>().getLogger(id, options)\n}\n\nfunction getGlobalSL<N extends string = LogMethodNames>(): StandardLogInstance<N> {\n\tif (!ctx.gsl) ctx.gsl = createStandardLogClosure()\n\n\treturn ctx.gsl!.standardLog as StandardLogInstance<N>\n}\n\nexport function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>) {\n\tif (ctx.configured) {\n\t\tconst log = ctx.gsl!.standardLog.getLogger('standard-log')\n\t\tlog.warn(\n\t\t\t'configGlobal() is being called more than once. Please make sure this is expected. Application should use `createStandardLog()` most of the time.'\n\t\t)\n\t}\n\n\tif (ctx.gsl) {\n\t\tif (options.logLevel) {\n\t\t\tctx.gsl.store.logLevel = options.logLevel\n\t\t}\n\t\tif (options.reporters) {\n\t\t\tconst reporters = ctx.gsl.store.reporters\n\t\t\treporters.length = 0\n\t\t\treporters.push(...options.reporters)\n\t\t}\n\t} else {\n\t\tctx.gsl = createStandardLogClosure(options)\n\t}\n\tctx.configured = true\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { type MemoryLogReporter } from './memory.js';
2
+ import { type StandardLog } from './standard_log.js';
3
+ import type { LogMethodNames, StandardLogOptions } from './types.js';
4
+ export type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
5
+ reporter: MemoryLogReporter;
6
+ };
7
+ export declare function createStandardLogForTest<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLogForTest<N>;
8
+ //# sourceMappingURL=standard_log.mocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard_log.mocks.d.ts","sourceRoot":"","sources":["../ts/standard_log.mocks.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpE,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IACpF,QAAQ,EAAE,iBAAiB,CAAA;CAC3B,CAAA;AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,EACzE,OAAO,GAAE,kBAAkB,CAAC,CAAC,CAAM,GACjC,kBAAkB,CAAC,CAAC,CAAC,CAUvB"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.createStandardLogForTest = void 0;
15
+ var log_levels_js_1 = require("./log_levels.js");
16
+ var memory_js_1 = require("./memory.js");
17
+ var standard_log_js_1 = require("./standard_log.js");
18
+ function createStandardLogForTest(options) {
19
+ var _a, _b;
20
+ if (options === void 0) { options = {}; }
21
+ options.logLevel = (_a = options.logLevel) !== null && _a !== void 0 ? _a : log_levels_js_1.logLevels.debug;
22
+ options.reporters = (_b = options.reporters) !== null && _b !== void 0 ? _b : [];
23
+ var existingReporter = options.reporters.find(function (r) { return r.id === 'memory'; });
24
+ var reporter = existingReporter !== null && existingReporter !== void 0 ? existingReporter : (0, memory_js_1.createMemoryLogReporter)();
25
+ if (!existingReporter) {
26
+ options.reporters.push(reporter);
27
+ }
28
+ var closure = (0, standard_log_js_1.createStandardLogClosure)(options);
29
+ return __assign(__assign({}, closure.standardLog), { reporter: reporter });
30
+ }
31
+ exports.createStandardLogForTest = createStandardLogForTest;
32
+ //# sourceMappingURL=standard_log.mocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard_log.mocks.js","sourceRoot":"","sources":["../ts/standard_log.mocks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iDAA2C;AAC3C,yCAA6E;AAC7E,qDAA8E;AAO9E,SAAgB,wBAAwB,CACvC,OAAmC;;IAAnC,wBAAA,EAAA,YAAmC;IAEnC,OAAO,CAAC,QAAQ,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,yBAAS,CAAC,KAAK,CAAA;IACtD,OAAO,CAAC,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,EAAE,CAAA;IAC3C,IAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAjB,CAAiB,CAAsB,CAAA;IAC5F,IAAM,QAAQ,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,IAAA,mCAAuB,GAAE,CAAA;IAC9D,IAAI,CAAC,gBAAgB,EAAE;QACtB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KAChC;IACD,IAAM,OAAO,GAAG,IAAA,0CAAwB,EAAI,OAAO,CAAC,CAAA;IACpD,6BAAY,OAAO,CAAC,WAAW,KAAE,QAAQ,UAAA,IAAE;AAC5C,CAAC;AAZD,4DAYC","sourcesContent":["import { logLevels } from './log_levels.js'\nimport { createMemoryLogReporter, type MemoryLogReporter } from './memory.js'\nimport { createStandardLogClosure, type StandardLog } from './standard_log.js'\nimport type { LogMethodNames, StandardLogOptions } from './types.js'\n\nexport type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {\n\treporter: MemoryLogReporter\n}\n\nexport function createStandardLogForTest<N extends string = LogMethodNames>(\n\toptions: StandardLogOptions<N> = {}\n): StandardLogForTest<N> {\n\toptions.logLevel = options.logLevel ?? logLevels.debug\n\toptions.reporters = options.reporters ?? []\n\tconst existingReporter = options.reporters.find(r => r.id === 'memory') as MemoryLogReporter\n\tconst reporter = existingReporter ?? createMemoryLogReporter()\n\tif (!existingReporter) {\n\t\toptions.reporters.push(reporter)\n\t}\n\tconst closure = createStandardLogClosure<N>(options)\n\treturn { ...closure.standardLog, reporter }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { createStandardLogForTest, type StandardLogForTest } from '../standard_log.mocks.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createStandardLogForTest = void 0;
4
+ var standard_log_mocks_js_1 = require("../standard_log.mocks.js");
5
+ Object.defineProperty(exports, "createStandardLogForTest", { enumerable: true, get: function () { return standard_log_mocks_js_1.createStandardLogForTest; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/testing/index.ts"],"names":[],"mappings":";;;AAAA,kEAA4F;AAAnF,iIAAA,wBAAwB,OAAA","sourcesContent":["export { createStandardLogForTest, type StandardLogForTest } from '../standard_log.mocks.js'\n"]}