standard-log 11.5.1 → 11.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/cjs/console.d.ts +3 -3
  2. package/cjs/console.d.ts.map +1 -1
  3. package/cjs/console.js +17 -8
  4. package/cjs/console.js.map +1 -1
  5. package/cjs/errors.d.ts.map +1 -1
  6. package/cjs/errors.js.map +1 -1
  7. package/cjs/formatter.d.ts +1 -1
  8. package/cjs/formatter.d.ts.map +1 -1
  9. package/cjs/formatter.js.map +1 -1
  10. package/cjs/index.d.ts.map +1 -1
  11. package/cjs/index.js.map +1 -1
  12. package/cjs/logLevels.d.ts.map +1 -1
  13. package/cjs/logLevels.js.map +1 -1
  14. package/cjs/logStore.d.ts.map +1 -1
  15. package/cjs/logStore.js.map +1 -1
  16. package/cjs/logger.d.ts.map +1 -1
  17. package/cjs/logger.js +15 -13
  18. package/cjs/logger.js.map +1 -1
  19. package/cjs/memory.d.ts +2 -2
  20. package/cjs/memory.d.ts.map +1 -1
  21. package/cjs/memory.js +15 -8
  22. package/cjs/memory.js.map +1 -1
  23. package/cjs/platform.d.ts.map +1 -1
  24. package/cjs/platform.js +1 -2
  25. package/cjs/platform.js.map +1 -1
  26. package/cjs/standardLog.ctx.d.ts.map +1 -1
  27. package/cjs/standardLog.ctx.js.map +1 -1
  28. package/cjs/standardLog.d.ts +2 -2
  29. package/cjs/standardLog.d.ts.map +1 -1
  30. package/cjs/standardLog.js +19 -14
  31. package/cjs/standardLog.js.map +1 -1
  32. package/cjs/types.d.ts +12 -12
  33. package/cjs/types.d.ts.map +1 -1
  34. package/cjs/types.js.map +1 -1
  35. package/dist/standard-log.es5.js +1090 -700
  36. package/dist/standard-log.es5.js.gz +0 -0
  37. package/dist/standard-log.es5.js.map +1 -1
  38. package/dist/standard-log.es5.js.map.gz +0 -0
  39. package/dist/standard-log.esm.js +167 -113
  40. package/dist/standard-log.esm.js.gz +0 -0
  41. package/dist/standard-log.esm.js.map +1 -1
  42. package/dist/standard-log.esm.js.map.gz +0 -0
  43. package/esm/console.d.ts +3 -3
  44. package/esm/console.d.ts.map +1 -1
  45. package/esm/console.js +20 -9
  46. package/esm/console.js.map +1 -1
  47. package/esm/errors.d.ts.map +1 -1
  48. package/esm/errors.js.map +1 -1
  49. package/esm/formatter.d.ts +1 -1
  50. package/esm/formatter.d.ts.map +1 -1
  51. package/esm/formatter.js.map +1 -1
  52. package/esm/index.d.ts.map +1 -1
  53. package/esm/index.js.map +1 -1
  54. package/esm/logLevels.d.ts.map +1 -1
  55. package/esm/logLevels.js.map +1 -1
  56. package/esm/logStore.d.ts.map +1 -1
  57. package/esm/logStore.js.map +1 -1
  58. package/esm/logger.d.ts.map +1 -1
  59. package/esm/logger.js +1 -1
  60. package/esm/logger.js.map +1 -1
  61. package/esm/memory.d.ts +2 -2
  62. package/esm/memory.d.ts.map +1 -1
  63. package/esm/memory.js +15 -8
  64. package/esm/memory.js.map +1 -1
  65. package/esm/platform.d.ts.map +1 -1
  66. package/esm/platform.js +1 -2
  67. package/esm/platform.js.map +1 -1
  68. package/esm/standardLog.ctx.d.ts.map +1 -1
  69. package/esm/standardLog.ctx.js.map +1 -1
  70. package/esm/standardLog.d.ts +2 -2
  71. package/esm/standardLog.d.ts.map +1 -1
  72. package/esm/standardLog.js +23 -18
  73. package/esm/standardLog.js.map +1 -1
  74. package/esm/types.d.ts +12 -12
  75. package/esm/types.d.ts.map +1 -1
  76. package/esm/types.js.map +1 -1
  77. package/package.json +14 -8
  78. package/ts/console.ts +54 -45
  79. package/ts/errors.ts +6 -6
  80. package/ts/formatter.ts +18 -18
  81. package/ts/index.ts +21 -6
  82. package/ts/logLevels.ts +90 -91
  83. package/ts/logStore.ts +46 -37
  84. package/ts/logger.ts +67 -57
  85. package/ts/memory.ts +66 -54
  86. package/ts/platform.ts +2 -2
  87. package/ts/standardLog.ctx.ts +2 -2
  88. package/ts/standardLog.ts +113 -94
  89. package/ts/types.ts +72 -62
package/cjs/console.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { ConsoleLike, LogFormatter, LogReporter, LogReporterOptions } from './types.js';
2
2
  export declare function toConsoleMethod(level: number): "error" | "warn" | "info" | "debug";
3
- export declare type ConsoleLogFormatter = LogFormatter<any[]>;
4
- export declare type ConsoleLogReporter = LogReporter<any[]> & {
3
+ export type ConsoleLogFormatter = LogFormatter<any[]>;
4
+ export type ConsoleLogReporter = LogReporter<any[]> & {
5
5
  console: ConsoleLike;
6
6
  };
7
- export declare type ConsoleLogReporterOptions = LogReporterOptions<any[]>;
7
+ export type ConsoleLogReporterOptions = LogReporterOptions<any[]>;
8
8
  export declare function createConsoleLogReporter(options?: ConsoleLogReporterOptions): ConsoleLogReporter;
9
9
  //# sourceMappingURL=console.d.ts.map
@@ -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,uCAS5C;AAiCD,oBAAY,mBAAmB,GAAG,YAAY,CAAC,GAAG,EAAE,CAAC,CAAA;AACrD,oBAAY,kBAAkB,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,GAAG;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAA;AAC9E,oBAAY,yBAAyB,GAAG,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAA;AAEjE,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CAiBhG"}
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"}
package/cjs/console.js CHANGED
@@ -8,11 +8,16 @@ 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
- case (level <= 0): return 'debug';
12
- case (level <= logLevels_js_1.logLevels.error): return 'error';
13
- case (level <= logLevels_js_1.logLevels.warn): return 'warn';
14
- case (level <= logLevels_js_1.logLevels.info): return 'info';
15
- default: return 'debug';
11
+ case level <= 0:
12
+ return 'debug';
13
+ case level <= logLevels_js_1.logLevels.error:
14
+ return 'error';
15
+ case level <= logLevels_js_1.logLevels.warn:
16
+ return 'warn';
17
+ case level <= logLevels_js_1.logLevels.info:
18
+ return 'info';
19
+ default:
20
+ return 'debug';
16
21
  }
17
22
  }
18
23
  exports.toConsoleMethod = toConsoleMethod;
@@ -36,7 +41,7 @@ function buildPolyfillConsole() {
36
41
  debug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),
37
42
  info: buildFn(typeof console.info === 'function' ? 'info' : 'log'),
38
43
  warn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),
39
- error: buildFn(typeof console.error === 'function' ? 'error' : 'log'),
44
+ error: buildFn(typeof console.error === 'function' ? 'error' : 'log')
40
45
  };
41
46
  }
42
47
  }
@@ -57,8 +62,12 @@ function createConsoleLogReporter(options) {
57
62
  return Object.freeze({
58
63
  id: id,
59
64
  isConsoleReporter: true,
60
- get formatter() { return formatter; },
61
- get filter() { return filter; },
65
+ get formatter() {
66
+ return formatter;
67
+ },
68
+ get filter() {
69
+ return filter;
70
+ },
62
71
  console: platform_js_1.polyfill.console,
63
72
  write: function (entry) {
64
73
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"console.js","sourceRoot":"","sources":["../ts/console.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,+CAAiD;AACjD,+CAA0C;AAC1C,6CAAwC;AAGxC,SAAgB,eAAe,CAAC,KAAa;IAC3C,QAAQ,IAAI,EAAE;QACZ,4CAA4C;QAC5C,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,CAAA;QACjC,KAAK,CAAC,KAAK,IAAI,wBAAS,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,CAAA;QAC/C,KAAK,CAAC,KAAK,IAAI,wBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,MAAM,CAAA;QAC7C,KAAK,CAAC,KAAK,IAAI,wBAAS,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,MAAM,CAAA;QAC7C,OAAO,CAAC,CAAC,OAAO,OAAO,CAAA;KACxB;AACH,CAAC;AATD,0CASC;AAED,uBAAuB;AACvB,+BAA+B;AAC/B,SAAS,oBAAoB;IAC3B,4CAA4C;IAC5C,IAAM,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAe,CAAA;IAC7C,IAAI,OAAO,EAAE;QACX,OAAO;YACL,6DAA6D;YAC7D,uEAAuE;YACvE,KAAK,EAAE,CAAC,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;YACvF,IAAI,EAAE,CAAC,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CA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EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,+BAAgB,EAAE,EAAE,OAAO,CAAC,EAA5F,EAAE,QAAA,EAAE,SAAS,eAAA,EAAE,MAAM,YAAuE,CAAA;IACpG,IAAI,CAAC,sBAAQ,CAAC,OAAO;QAAE,sBAAQ,CAAC,OAAO,GAAG,oBAAoB,EAAE,CAAA;IAEhE,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE,IAAA;QACF,iBAAiB,EAAE,IAAI;QACvB,IAAI,SAAS,KAAK,OAAO,SAAS,CAAA,CAAC,CAAC;QACpC,IAAI,MAAM,KAAK,OAAO,MAAM,CAAA,CAAC,CAAC;QAC9B,OAAO,EAAE,sBAAQ,CAAC,OAAO;QACzB,KAAK,YAAC,KAAe;;YACnB,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;QACjC,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAjBD,4DAiBC","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 switch (true) {\n // edge case in case none is somehow written\n case (level <= 0): return 'debug'\n case (level <= logLevels.error): return 'error'\n case (level <= logLevels.warn): return 'warn'\n case (level <= logLevels.info): return 'info'\n default: return 'debug'\n }\n}\n\n// istanbul ignore next\n/* eslint-disable no-console */\nfunction buildPolyfillConsole() {\n // old phantomjs does not have bind function\n const hasBind = !!console.log.bind as boolean\n if (hasBind) {\n return {\n // the `typeof` guards against IE where `console.log.apply()`\n // results in error `Object doesn't support property or method 'apply'`\n debug: (typeof console.info === 'function' ? console.debug : console.log).bind(console),\n info: (typeof console.info === 'function' ? console.info : console.log).bind(console),\n warn: (typeof console.warn === 'function' ? console.warn : console.log).bind(console),\n error: (typeof console.error === 'function' ? console.error : console.log).bind(console)\n }\n }\n else {\n return {\n debug: buildFn(typeof console.debug === 'function' ? 'debug' : 'log'),\n info: buildFn(typeof console.info === 'function' ? 'info' : 'log'),\n warn: buildFn(typeof console.warn === 'function' ? 'warn' : 'log'),\n error: buildFn(typeof console.error === 'function' ? 'error' : 'log'),\n }\n }\n}\n\n// istanbul ignore next\nfunction buildFn(name: 'debug' | 'info' | 'warn' | 'error' | 'log') {\n return function (...args: any[]) { console[name](...args) }\n}\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 const { id, formatter, filter } = unpartial({ id: 'console', formatter: consoleFormatter }, options)\n if (!polyfill.console) polyfill.console = buildPolyfillConsole()\n\n return Object.freeze({\n id,\n isConsoleReporter: true,\n get formatter() { return formatter },\n get filter() { return filter },\n console: polyfill.console,\n write(entry: LogEntry) {\n if (filter && !filter(entry)) return\n const values = formatter(entry)\n const method = toConsoleMethod(entry.level)\n this.console[method](...values)\n }\n })\n}\n"]}
1
+ {"version":3,"file":"console.js","sourceRoot":"","sources":["../ts/console.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,+CAAiD;AACjD,+CAA0C;AAC1C,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,wBAAS,CAAC,KAAK;YAC5B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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 +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;gBACnC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG5D;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,gBAAgB;IAC1B,EAAE,EAAE,MAAM;gBAAV,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO;CAG1D"}
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"}
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;IAC/C,0BAAY,WAAmB,EAAE,OAA0B;eACzD,kBAAM,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC;IAC7C,CAAC;IACH,uBAAC;AAAD,CAAC,AAJD,CAAsC,uBAAW,GAIhD;AAJY,4CAAgB;AAM7B;;GAEG;AACH;IAA+B,6BAAgB;IAC7C,mBAAmB,EAAU,EAAE,OAA0B;QAAzD,YACE,kBAAM,yFAAkF,EAAE,CAAE,EAAE,OAAO,CAAC,SACvG;;;;;mBAFkB;;;IAEnB,CAAC;IACH,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 constructor(description: string, options?: IsoError.Options) {\n super('standard-log', description, options)\n }\n}\n\n/**\n * @deprecated no longer used since 11.2.0\n */\nexport class InvalidId extends StandardLogError {\n constructor(public id: string, options?: IsoError.Options) {\n super(`logger id only supports alphanumeric, unicode characters, and [:_-.]. Received ${id}`, options)\n }\n}\n"]}
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,5 +1,5 @@
1
1
  import type { LogEntry } from './types.js';
2
- export declare type TimestampFormat = 'none' | 'iso' | 'elapsed';
2
+ export type TimestampFormat = 'none' | 'iso' | 'elapsed';
3
3
  export declare function createTimestampFormatter(format: TimestampFormat): (timestamp: Date) => string | undefined;
4
4
  export declare function formatLogLevel(level: number): string;
5
5
  /**
@@ -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,oBAAY,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":"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 +1 @@
1
- {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAAmB;AACnB,yCAAsC;AACtC,+CAA+C;AAK/C,SAAgB,wBAAwB,CAAC,MAAuB;IAC9D,QAAQ,MAAM,EAAE;QACd,KAAK,MAAM;YACT,OAAO,UAAC,UAAgB,IAAK,OAAA,SAAS,EAAT,CAAS,CAAA;QACxC,KAAK,KAAK;YACR,OAAO,UAAC,SAAe,IAAK,OAAA,SAAS,CAAC,WAAW,EAAE,EAAvB,CAAuB,CAAA;QACrD,KAAK,SAAS,CAAC,CAAC;YACd,IAAI,UAAgB,CAAA;YACpB,OAAO,UAAC,SAAe;gBACrB,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;YACf,CAAC,CAAA;SACF;KACF;AACH,CAAC;AAhBD,4DAgBC;AAED,SAAgB,cAAc,CAAC,KAAa;IAC1C,OAAO,WAAI,IAAA,sBAAS,EAAC,IAAA,6BAAc,EAAC,KAAK,CAAC,CAAC,MAAG,CAAA;AAChD,CAAC;AAFD,wCAEC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,EAAwC;QAAtC,EAAE,QAAA,EAAE,KAAK,WAAA,EAAE,IAAI,UAAA,EAAE,SAAS,eAAA;IAC5D,sBAAQ,SAAS,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,GAAK,IAAI,QAAC;AACtE,CAAC;AAFD,8CAEC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,EAAkB;QAAhB,IAAI,UAAA;IACrC,OAAO,IAAI,CAAA;AACb,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 switch (format) {\n case 'none':\n return (_timestamp: Date) => undefined\n case 'iso':\n return (timestamp: Date) => timestamp.toISOString()\n case 'elapsed': {\n let lastTick: number\n return (timestamp: Date) => {\n const newTick = timestamp.getTime()\n const result = ms(lastTick === undefined ? 0 : newTick - lastTick)\n lastTick = newTick\n return result\n }\n }\n }\n}\n\nexport function formatLogLevel(level: number) {\n return `(${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 return [timestamp.toISOString(), id, formatLogLevel(level), ...args]\n}\n\n/**\n * Formats log entry like default console log.\n */\nexport function consoleFormatter({ args }: LogEntry) {\n return args\n}\n"]}
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../ts/formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAAmB;AACnB,yCAAsC;AACtC,+CAA+C;AAK/C,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,6BAAc,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 './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 +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,EACL,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EACzD,SAAS,EAAE,YAAY,EACxB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAClF,YAAY,EACV,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAC5F,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EACzF,mBAAmB,EAAE,kBAAkB,EACxC,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,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"}
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,mDAGyB;AAFvB,8GAAA,YAAY,OAAA;AAAE,mHAAA,iBAAiB,OAAA;AAAE,0HAAA,wBAAwB,OAAA;AACzD,2GAAA,SAAS,OAAA;AAAE,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 configGlobal, createStandardLog, createStandardLogForTest,\n getLogger, suppressLogs\n} from './standardLog.js'\nexport type { GetLogger, StandardLog, StandardLogForTest } from './standardLog.js'\nexport type {\n ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, Logger, LoggerOptions, LogLevel,\n LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, ReporterFilter,\n StandardLogInstance, StandardLogOptions\n} from './types.js'\n\n"]}
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 +1 @@
1
- {"version":3,"file":"logLevels.d.ts","sourceRoot":"","sources":["../ts/logLevels.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,SAAS;IACpB;;OAEG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;;;OAKG;;IAEH;;OAEG;;CAEJ,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"}
1
+ {"version":3,"file":"logLevels.d.ts","sourceRoot":"","sources":["../ts/logLevels.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"}
@@ -1 +1 @@
1
- {"version":3,"file":"logLevels.js","sourceRo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rD,CAAC;AAFD,gCAEC;AAEY,QAAA,wBAAwB,GAAa;IAChD,WAAW;IACX,OAAO;IACP,UAAU;IACV,OAAO;IACP,MAAM;IACN,QAAQ;IACR,MAAM;IACN,OAAO;IACP,OAAO;IACP,QAAQ;CACT,CAAA","sourcesContent":["\nexport const logLevels = {\n /**\n * none: 0\n */\n none: 0 as const,\n /**\n * emergency: 100\n *\n * emergency -> alert\n */\n emergency: 100 as const,\n /**\n * alert: 200\n *\n * emergency -> alert -> critical\n */\n alert: 200 as const,\n /**\n * critical: 300\n *\n * alert -> critical -> error\n */\n critical: 300 as const,\n /**\n * error: 400\n *\n * critical -> error -> warn\n */\n error: 400 as const,\n /**\n * warn: 500\n *\n * error -> warn -> notice\n */\n warn: 500 as const,\n /**\n * notice: 600\n *\n * warn -> notice -> info\n */\n notice: 600 as const,\n /**\n * info: 700\n *\n * notice -> info -> debug\n */\n info: 700 as const,\n /**\n * debug: 800\n *\n * info -> debug -> trace\n */\n debug: 800 as const,\n /**\n * trace: 900\n *\n * debug -> trace -> planck\n */\n trace: 900 as const,\n /**\n * planck: Infinity\n * `planck unit` is a very small unit <https://en.wikipedia.org/wiki/Planck_units>.\n *\n * trace -> planck\n */\n planck: Infinity,\n /**\n * all: Infinity\n */\n all: Infinity\n}\n\n/**\n * Convert default log level value to log level name.\n */\nexport function toLogLevelName(level: number) {\n if (level <= 100) return 'emergency'\n if (level <= 200) return 'alert'\n if (level <= 300) return 'critical'\n if (level <= 400) return 'error'\n if (level <= 500) return 'warn'\n if (level <= 600) return 'notice'\n if (level <= 700) return 'info'\n if (level <= 800) return 'debug'\n if (level <= 900) return 'trace'\n return 'planck'\n}\n\n/**\n * Convert default log level name to log level value.\n */\nexport function toLogLevel(name: string): number | undefined {\n return (logLevels as any)[name.toLocaleLowerCase()]\n}\n\nexport const DEFAULT_LOG_METHOD_NAMES: string[] = [\n 'emergency',\n 'alert',\n 'critical',\n 'error',\n 'warn',\n 'notice',\n 'info',\n 'debug',\n 'trace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AAiB,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 +1 @@
1
- {"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../ts/logStore.ts"],"names":[],"mappings":"AAIA,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,EAAE,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAQpH;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;CAChD;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACtC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;mBAWxC,MAAM;mBAGN,MAAM;;;;;EAWxB"}
1
+ {"version":3,"file":"logStore.d.ts","sourceRoot":"","sources":["../ts/logStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,kBAAkB,E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AAE,IAAA,uBAAW,EAAC,YAAY,EAAE,UAAC,CAAC,EAAE,CAAC;YAClD,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;YACtB,OAAO,CAAC,CAAA;QACV,CAAC,EAAE,EAA4B,CAAC;KACjC,CAAA;IACD,OAAO;QACL,OAAO,YAAC,KAAa;;YACnB,OAAO,MAAA,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,mCAAI,IAAA,6BAAc,EAAC,KAAK,CAAC,CAAA;QAClE,CAAC;QACD,QAAQ,YAAC,IAAY;;YACnB,OAAO,MAAA,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,mCAAI,IAAA,yBAAU,EAAC,IAAI,CAAC,CAAA;QACrD,CAAC;QACD,YAAY;YACV,OAAO,IAAA,qBAAS,EAAC,wBAAS,EAAE,UAAC,MAAM,EAAE,IAAI;gBACvC,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,KAAK;oBAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,MAAA,EAAE,KAAK,EAAE,wBAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAEpF,OAAO,MAAM,CAAA;YACf,CAAC,EAAE,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,CAAC,CAAA;QACrF,CAAC;KACF,CAAA;AACH,CAAC;AAzBD,sCAyBC","sourcesContent":["\nimport { mapKey, record, reduceByKey, reduceKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './logLevels.js'\nimport type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore<N extends string = LogMethodNames>(options: Required<StandardLogOptions<N>>): LogStore {\n return {\n loggers: record(),\n nonConsoleLoggers: record(),\n reporters: options.reporters || [createConsoleLogReporter()],\n logLevel: options.logLevel,\n logLevelStore: logLevelStore(options)\n }\n}\n\nexport interface LogStore {\n loggers: Record<string, Logger>,\n nonConsoleLoggers: Record<string, Logger>,\n reporters: LogReporter[],\n logLevel: LogLevel,\n logLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n customLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n const customLevels = options.customLevels || record()\n\n const store = {\n customLevels,\n customLevelsReverse: reduceByKey(customLevels, (p, k) => {\n p[customLevels[k]] = k\n return p\n }, {} as Record<number, string>)\n }\n return {\n getName(level: number) {\n return store.customLevelsReverse[level] ?? toLogLevelName(level)\n },\n getLevel(name: string) {\n return store.customLevels[name] ?? toLogLevel(name)\n },\n getAllLevels() {\n return reduceKey(logLevels, (result, name) => {\n if (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n return result\n }, mapKey(store.customLevels, name => ({ name, level: store.customLevels[name] })))\n }\n }\n}\n"]}
1
+ {"version":3,"file":"logStore.js","sourceRoot":"","sources":["../ts/logStore.ts"],"names":[],"mappings":";;;AAAA,uCAAkE;AAClE,2CAAuD;AACvD,+CAAsE;AAGtE,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,6BAAc,EAAC,KAAK,CAAC,CAAA;QACjE,CAAC;QACD,QAAQ,YAAC,IAAY;;YACpB,OAAO,MAAA,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,mCAAI,IAAA,yBAAU,EAAC,IAAI,CAAC,CAAA;QACpD,CAAC;QACD,YAAY;YACX,OAAO,IAAA,qBAAS,EACf,wBAAS,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,wBAAS,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 './logLevels.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 +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,EAC5D,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GACnD,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC,CAwD5B"}
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"}
package/cjs/logger.js CHANGED
@@ -33,19 +33,21 @@ function createLogger(store, id, options) {
33
33
  id: { value: id, writable: false },
34
34
  count: {
35
35
  writable: false,
36
- value: (function (counter) { return function () {
37
- var args = [];
38
- for (var _i = 0; _i < arguments.length; _i++) {
39
- args[_i] = arguments[_i];
40
- }
41
- if (shouldLog(store, logLevels_js_1.logLevels.debug, logger.level))
42
- write({
43
- id: id,
44
- level: logLevels_js_1.logLevels.debug,
45
- args: __spreadArray([++counter], args, true),
46
- timestamp: new Date()
47
- });
48
- }; })(0)
36
+ value: (function (counter) {
37
+ return function () {
38
+ var args = [];
39
+ for (var _i = 0; _i < arguments.length; _i++) {
40
+ args[_i] = arguments[_i];
41
+ }
42
+ if (shouldLog(store, logLevels_js_1.logLevels.debug, logger.level))
43
+ write({
44
+ id: id,
45
+ level: logLevels_js_1.logLevels.debug,
46
+ args: __spreadArray([++counter], args, true),
47
+ timestamp: new Date()
48
+ });
49
+ };
50
+ })(0)
49
51
  },
50
52
  on: {
51
53
  writable: false,
package/cjs/logger.js.map CHANG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,CAAC,SAAS,SAAS,CAAC,EAAe;YAAb,IAAI,UAAA,EAAE,KAAK,WAAA;QACzE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE;YAClC,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE;gBAAC,cAAc;qBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;oBAAd,yBAAc;;gBACpB,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;YAC9F,CAAC;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC;AA1DD,oCA0DC;AAED,SAAS,UAAU,CAAC,EAAU;IAC5B,OAAO,EAAE,CAAC,OAAO,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAwB,EAAE,QAAkB,EAAE,MAAuC;IAC7G,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;AACtE,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAe,EAAE,WAAqB,EAAE,WAAiC;IAC1F,OAAO,WAAW,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;AAClF,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 store: LogStore, id: string, options?: LoggerOptions\n): Logger<N | LogMethodNames> {\n id = sanitizeId(id)\n const writeTo = options?.writeTo ?? (() => true)\n const [filter, reporters]: [(reporterId: string) => boolean, LogReporter[]] = typeof writeTo === 'string'\n ? [id => id === writeTo, store.reporters]\n : writeTo instanceof RegExp\n ? [id => writeTo.test(id), store.reporters]\n : typeof writeTo === 'function'\n ? [writeTo, store.reporters]\n : [() => true, [writeTo]]\n\n function write(entry: LogEntry) {\n writeToReporters(reporters, entry, filter)\n }\n\n const logger = {\n level: options?.level,\n write\n } as any\n\n Object.defineProperties(logger, {\n id: { value: id, writable: false },\n count: {\n writable: false,\n value: ((counter) => (...args: any[]) => {\n if (shouldLog(store, logLevels.debug, logger.level))\n write({\n id,\n level: logLevels.debug,\n args: [++counter, ...args],\n timestamp: new Date()\n })\n })(0)\n },\n on: {\n writable: false,\n value: (level: number | N | LogMethodNames, logFn: LogFunction) => {\n const logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level)! : level\n if (shouldLog(store, logLevel, logger.level)) {\n const methodName = store.logLevelStore.getName(logLevel)\n const bindedMethod = logger[methodName].bind(logger)\n const result = logFn(bindedMethod, logger.level ?? store.logLevel)\n if (result) bindedMethod(result)\n }\n }\n }\n })\n store.logLevelStore.getAllLevels().forEach(function addMethod({ name, level }) {\n Object.defineProperty(logger, name, {\n writable: false,\n value: (...args: any[]) => {\n if (shouldLog(store, level, logger.level)) write({ id, level, args, timestamp: new Date() })\n }\n })\n })\n return logger\n}\n\nfunction sanitizeId(id: string) {\n return id.replace(/[`~!#$%^&*()=+[\\]{},|<>?]/g, '-')\n}\n\nfunction writeToReporters(reporters: LogReporter[], logEntry: LogEntry, filter: (reporterId: string) => boolean) {\n reporters.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 return targetLevel <= (loggerLevel !== undefined ? loggerLevel : store.logLevel)\n}\n"]}
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,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;gBAC5B,CAAC,CAAC,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,EAAE,CAAC,OAAO,CAAC,CAAC,EAPpB,MAAM,QAAA,EAAE,SAAS,QAOG,CAAA;IAE3B,SAAS,KAAK,CAAC,KAAe;QAC7B,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;IAED,IAAM,MAAM,GAAG;QACd,KAAK,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK;QACrB,KAAK,OAAA;KACE,C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A;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"]}
package/cjs/memory.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js';
2
- export declare type MemoryLogReporter = LogReporter<LogEntry> & {
2
+ export type MemoryLogReporter = LogReporter<LogEntry> & {
3
3
  logs: LogEntry[];
4
4
  /**
5
5
  * Gets a simple log message for testing.
@@ -11,7 +11,7 @@ export declare type MemoryLogReporter = LogReporter<LogEntry> & {
11
11
  getLogMessagesWithIdAndLevel(): string[];
12
12
  emit(): void;
13
13
  };
14
- export declare type MemoryLogFormatter = LogFormatter<LogEntry>;
14
+ export type MemoryLogFormatter = LogFormatter<LogEntry>;
15
15
  export declare function toMessageWithLevel(logs: LogEntry[]): string;
16
16
  export declare function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
17
17
  export declare function createMemoryWithConsoleLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
@@ -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,oBAAY,iBAAiB,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG;IACtD,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB;;;OAGG;IACH,aAAa,IAAI,MAAM,CAAC;IACxB,cAAc,IAAI,MAAM,EAAE,CAAC;IAC3B,sBAAsB,IAAI,MAAM,CAAC;IACjC,4BAA4B,IAAI,MAAM,EAAE,CAAC;IACzC,IAAI,IAAI,IAAI,CAAA;CACb,CAAA;AAED,oBAAY,kBAAkB,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AAEvD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAQlD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAEjG;AAoCD,wBAAgB,kCAAkC,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAK5G"}
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../ts/memory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGzF,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG;IACvD,IAAI,EAAE,QAAQ,EAAE,CAAA;IAChB;;;OAGG;IACH,aAAa,IAAI,MAAM,CAAA;IACvB,cAAc,IAAI,MAAM,EAAE,CAAA;IAC1B,sBAAsB,IAAI,MAAM,CAAA;IAChC,4BAA4B,IAAI,MAAM,EAAE,CAAA;IACxC,IAAI,IAAI,IAAI,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;AAEvD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAWlD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAEjG;AA0CD,wBAAgB,kCAAkC,CACjD,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GACpC,iBAAiB,CAMnB"}
package/cjs/memory.js CHANGED
@@ -6,13 +6,14 @@ var platform_js_1 = require("./platform.js");
6
6
  var formatter_js_1 = require("./formatter.js");
7
7
  var console_js_1 = require("./console.js");
8
8
  function toMessageWithLevel(logs) {
9
- return logs.map(platform_js_1.toInspectLogEntry)
9
+ return (logs
10
+ .map(platform_js_1.toInspectLogEntry)
10
11
  .map(function (log) { return "".concat((0, formatter_js_1.formatLogLevel)(log.level), " ").concat(log.args.join(' ')); })
11
12
  .join('\n')
12
13
  // if it has more than this log,
13
14
  // we assume it is running under tests,
14
15
  // and remove this log to simplify testing.
15
- .replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, '');
16
+ .replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, ''));
16
17
  }
17
18
  exports.toMessageWithLevel = toMessageWithLevel;
18
19
  function createMemoryLogReporter(options) {
@@ -24,8 +25,12 @@ function buildMemoryReporter(options) {
24
25
  var logs = [];
25
26
  return {
26
27
  id: id,
27
- get formatter() { return formatter; },
28
- get filter() { return filter; },
28
+ get formatter() {
29
+ return formatter;
30
+ },
31
+ get filter() {
32
+ return filter;
33
+ },
29
34
  logs: logs,
30
35
  write: function (entry) {
31
36
  if (filter && !filter(entry))
@@ -36,14 +41,16 @@ function buildMemoryReporter(options) {
36
41
  return this.getLogMessages().join('\n');
37
42
  },
38
43
  getLogMessages: function () {
39
- return logs.map(platform_js_1.toInspectLogEntry)
40
- .map(function (log) { return log.args.join(' '); });
44
+ return logs.map(platform_js_1.toInspectLogEntry).map(function (log) { return log.args.join(' '); });
41
45
  },
42
46
  getLogMessagesWithIdAndLevel: function () {
43
- return logs.map(platform_js_1.toInspectLogEntry)
47
+ return logs
48
+ .map(platform_js_1.toInspectLogEntry)
44
49
  .map(function (log) { return "".concat(log.id, " ").concat((0, formatter_js_1.formatLogLevel)(log.level), " ").concat(log.args.join(' ')); });
45
50
  },
46
- getLogMessageWithLevel: function () { return toMessageWithLevel(logs); },
51
+ getLogMessageWithLevel: function () {
52
+ return toMessageWithLevel(logs);
53
+ },
47
54
  /**
48
55
  * emit the saved log to console for easy debugging
49
56
  */
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;AAiBvD,SAAgB,kBAAkB,CAAC,IAAgB;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,+BAAiB,CAAC;SAC/B,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,CAAA;AACrF,CAAC;AARD,gDAQC;AAED,SAAgB,uBAAuB,CAAC,OAAsC;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;AACjF,CAAC;AAF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I,CAAC,CAAA,CAAC,CAAC;QAC5D;;WAEG;QACH,IAAI;YACF,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;QACtC,CAAC;KACF,CAAA;AACH,CAAC;AAED,SAAgB,kCAAkC,CAAC,OAAsC;IACvF,OAAO,MAAM,CAAC,MAAM,CAClB,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAA,qBAAS,EAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE;QACpF,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC,CAAA;AACP,CAAC;AALD,gFAKC","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 logs: LogEntry[],\n /**\n * Gets a simple log message for testing.\n * The message only contains arguments for each log entry.\n */\n getLogMessage(): string,\n getLogMessages(): string[],\n getLogMessageWithLevel(): string,\n getLogMessagesWithIdAndLevel(): string[],\n emit(): void\n}\n\nexport type MemoryLogFormatter = LogFormatter<LogEntry>\n\nexport function toMessageWithLevel(logs: LogEntry[]) {\n return logs.map(toInspectLogEntry)\n .map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n .join('\\n')\n // if it has more than this log,\n // we assume it is running under tests,\n // and remove this log to simplify testing.\n .replace(/^\\(WARN\\) already configured for test, ignoring config\\(\\) call\\n/, '')\n}\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n return Object.freeze(buildMemoryReporter(unpartial({ id: 'memory' }, options)))\n}\n\nfunction buildMemoryReporter(options?: LogReporterOptions<LogEntry>) {\n const { id, formatter, filter } = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n const logs: LogEntry[] = []\n return {\n id,\n get formatter() { return formatter },\n get filter() { return filter },\n logs,\n write(entry: LogEntry) {\n if (filter && !filter(entry)) return\n logs.push(formatter(entry))\n },\n getLogMessage() {\n return this.getLogMessages().join('\\n')\n },\n getLogMessages() {\n return logs.map(toInspectLogEntry)\n .map(log => log.args.join(' '))\n },\n getLogMessagesWithIdAndLevel() {\n return logs.map(toInspectLogEntry)\n .map(log => `${log.id} ${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n },\n getLogMessageWithLevel() { return toMessageWithLevel(logs) },\n /**\n * emit the saved log to console for easy debugging\n */\n emit() {\n const reporter = createConsoleLogReporter()\n logs.forEach(l => reporter.write(l))\n }\n }\n}\n\nexport function createMemoryWithConsoleLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n return Object.freeze(\n Object.assign(buildMemoryReporter(unpartial({ id: 'memory-with-console' }, options)), {\n isConsoleReporter: true\n }))\n}\n"]}
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;AAiBvD,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,SAAg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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\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\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.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,aAEzC,CAAA;AAEJ,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,MAAO,QAAQ,aAE5C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAa,CAAA"}
package/cjs/platform.js CHANGED
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polyfill = exports.toInspectLogEntry = void 0;
4
4
  var type_plus_1 = require("type-plus");
5
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; }),
7
- e); };
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); };
8
7
  exports.toInspectLogEntry = toInspectLogEntry;
9
8
  exports.polyfill = (0, type_plus_1.record)();
10
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,CAChD,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAApE,CAAoE,CAAC;IAClG,CAAC,CAAC,EAF8C,CAE9C,CAAA;AAFS,QAAA,iBAAiB,qBAE1B;AAES,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 e.args = e.args.map(value => typeof value === 'object' && value !== null ? inspect(value) : value),\n e)\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"]}
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 +1 @@
1
- {"version":3,"file":"standardLog.ctx.d.ts","sourceRoot":"","sources":["../ts/standardLog.ctx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErE,eAAO,MAAM,GAAG,EAAE;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAC;QAAC,WAAW,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAA;KAAE,CAAA;CACjE,CAAA"}
1
+ {"version":3,"file":"standardLog.ctx.d.ts","sourceRoot":"","sources":["../ts/standardLog.ctx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErE,eAAO,MAAM,GAAG,EAAE;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,GAAG,CAAC,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAC;QAAC,WAAW,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAA;KAAE,CAAA;CAChE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"standardLog.ctx.js","sourceRoot":"","sources":["../ts/standardLog.ctx.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAIrB,QAAA,GAAG,GAGZ,IAAA,kBAAM,GAAE,CAAA","sourcesContent":["import { record } from 'type-plus'\nimport type { LogStore } from './logStore.js'\nimport type { LogMethodNames, StandardLogInstance } from './types.js'\n\nexport const ctx: {\n configured?: boolean,\n gsl?: { store: LogStore, standardLog: StandardLogInstance<LogMethodNames> }\n} = record()\n"]}
1
+ {"version":3,"file":"standardLog.ctx.js","sourceRoot":"","sources":["../ts/standardLog.ctx.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAIrB,QAAA,GAAG,GAGZ,IAAA,kBAAM,GAAE,CAAA","sourcesContent":["import { record } from 'type-plus'\nimport type { LogStore } from './logStore.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"]}
@@ -8,7 +8,7 @@ export declare function createStandardLogClosure<N extends string = LogMethodNam
8
8
  store: LogStore;
9
9
  standardLog: StandardLog<N>;
10
10
  };
11
- export declare type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
11
+ export type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
12
12
  reporter: MemoryLogReporter;
13
13
  };
14
14
  export declare function createStandardLogForTest<N extends string = LogMethodNames>(logLevel?: LogLevel): StandardLogForTest<N>;
@@ -16,7 +16,7 @@ export declare function createStandardLogForTest<N extends string = LogMethodNam
16
16
  * Suppress logging within the code block.
17
17
  */
18
18
  export declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
19
- export declare type GetLogger<N extends string = LogMethodNames> = (id: string, options?: LoggerOptions) => Logger<LogMethodNames | N>;
19
+ export type GetLogger<N extends string = LogMethodNames> = (id: string, options?: LoggerOptions) => Logger<LogMethodNames | N>;
20
20
  export declare function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions): Logger<LogMethodNames | N>;
21
21
  export declare function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>): void;
22
22
  //# sourceMappingURL=standardLog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standardLog.d.ts","sourceRoot":"","sources":["../ts/standardLog.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAA2B,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAExE,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAA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A;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"}
@@ -36,13 +36,17 @@ function createStandardLogClosure(options) {
36
36
  // TODO reporter.id must not be empty
37
37
  var store = (0, logStore_js_1.createLogStore)((0, type_plus_1.required)({ logLevel: logLevels_js_1.logLevels.info }, options));
38
38
  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
40
- .concat(Object.keys((_c = options === null || options === void 0 ? void 0 : options.customLevels) !== null && _c !== void 0 ? _c : {}))
41
- .concat(['on', 'count', 'write']);
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([
40
+ 'on',
41
+ 'count',
42
+ 'write'
43
+ ]);
42
44
  return {
43
45
  store: store,
44
46
  standardLog: {
45
- get logLevel() { return store.logLevel; },
47
+ get logLevel() {
48
+ return store.logLevel;
49
+ },
46
50
  toLogLevelName: function (level) {
47
51
  return store.logLevelStore.getName(level);
48
52
  },
@@ -52,7 +56,7 @@ function createStandardLogClosure(options) {
52
56
  getLogger: function (id, options) {
53
57
  if (store.loggers[id])
54
58
  return store.loggers[id];
55
- return store.loggers[id] = (0, logger_js_1.createLogger)(store, id, __assign({ ssf: this.getLogger }, options));
59
+ return (store.loggers[id] = (0, logger_js_1.createLogger)(store, id, __assign({ ssf: this.getLogger }, options)));
56
60
  },
57
61
  getNonConsoleLogger: function (id, options) {
58
62
  if (store.nonConsoleLoggers[id])
@@ -60,14 +64,15 @@ function createStandardLogClosure(options) {
60
64
  if (store.loggers[id]) {
61
65
  var log = this.getLogger('standard-log');
62
66
  log.warn("attempt to create a non-console logger with existing id ('".concat(id, "'), ignoring"));
63
- return store.nonConsoleLoggers[id] = createDummyLogger(logMethods);
67
+ return (store.nonConsoleLoggers[id] = createDummyLogger(logMethods));
64
68
  }
65
- return store.nonConsoleLoggers[id] = nonConsoleReporters.length === 0
66
- ? createDummyLogger(logMethods)
67
- : (0, logger_js_1.createLogger)(store, id, __assign(__assign({ ssf: this.getNonConsoleLogger }, options), { writeTo: function (reporterId) {
68
- return nonConsoleReporters.indexOf(reporterId) >= 0;
69
- } }));
70
- },
69
+ return (store.nonConsoleLoggers[id] =
70
+ nonConsoleReporters.length === 0
71
+ ? createDummyLogger(logMethods)
72
+ : (0, logger_js_1.createLogger)(store, id, __assign(__assign({ ssf: this.getNonConsoleLogger }, options), { writeTo: function (reporterId) {
73
+ return nonConsoleReporters.indexOf(reporterId) >= 0;
74
+ } })));
75
+ }
71
76
  }
72
77
  };
73
78
  }
@@ -91,9 +96,9 @@ function suppressLogs(block) {
91
96
  logs[_i - 1] = arguments[_i];
92
97
  }
93
98
  var origLevels = logs.map(function (l) { return l.level; });
94
- logs.forEach(function (l) { return l.level = logLevels_js_1.logLevels.none; });
99
+ logs.forEach(function (l) { return (l.level = logLevels_js_1.logLevels.none); });
95
100
  var result = block();
96
- logs.forEach(function (l, i) { return l.level = origLevels[i]; });
101
+ logs.forEach(function (l, i) { return (l.level = origLevels[i]); });
97
102
  return result;
98
103
  }
99
104
  exports.suppressLogs = suppressLogs;