standard-log 11.5.1 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +2 -3
  2. package/cjs/console.d.ts +3 -3
  3. package/cjs/console.d.ts.map +1 -1
  4. package/cjs/console.js +18 -9
  5. package/cjs/console.js.map +1 -1
  6. package/cjs/errors.d.ts.map +1 -1
  7. package/cjs/errors.js.map +1 -1
  8. package/cjs/formatter.d.ts +1 -1
  9. package/cjs/formatter.d.ts.map +1 -1
  10. package/cjs/formatter.js +2 -2
  11. package/cjs/formatter.js.map +1 -1
  12. package/cjs/index.d.ts +4 -4
  13. package/cjs/index.d.ts.map +1 -1
  14. package/cjs/index.js +7 -8
  15. package/cjs/index.js.map +1 -1
  16. package/cjs/{logLevels.d.ts → log_levels.d.ts} +1 -1
  17. package/cjs/log_levels.d.ts.map +1 -0
  18. package/cjs/{logLevels.js → log_levels.js} +1 -1
  19. package/cjs/log_levels.js.map +1 -0
  20. package/{esm/logStore.d.ts → cjs/log_store.d.ts} +1 -1
  21. package/cjs/log_store.d.ts.map +1 -0
  22. package/cjs/{logStore.js → log_store.js} +6 -6
  23. package/cjs/log_store.js.map +1 -0
  24. package/cjs/logger.d.ts +1 -1
  25. package/cjs/logger.d.ts.map +1 -1
  26. package/cjs/logger.js +16 -14
  27. package/cjs/logger.js.map +1 -1
  28. package/cjs/memory.d.ts +2 -2
  29. package/cjs/memory.d.ts.map +1 -1
  30. package/cjs/memory.js +15 -8
  31. package/cjs/memory.js.map +1 -1
  32. package/cjs/platform.d.ts.map +1 -1
  33. package/cjs/platform.js +1 -2
  34. package/cjs/platform.js.map +1 -1
  35. package/cjs/{standardLog.ctx.d.ts → standard_log.ctx.d.ts} +2 -2
  36. package/cjs/standard_log.ctx.d.ts.map +1 -0
  37. package/cjs/{standardLog.ctx.js → standard_log.ctx.js} +1 -1
  38. package/cjs/standard_log.ctx.js.map +1 -0
  39. package/{esm/standardLog.d.ts → cjs/standard_log.d.ts} +4 -9
  40. package/cjs/standard_log.d.ts.map +1 -0
  41. package/cjs/{standardLog.js → standard_log.js} +37 -40
  42. package/cjs/standard_log.js.map +1 -0
  43. package/cjs/standard_log.mocks.d.ts +8 -0
  44. package/cjs/standard_log.mocks.d.ts.map +1 -0
  45. package/cjs/standard_log.mocks.js +32 -0
  46. package/cjs/standard_log.mocks.js.map +1 -0
  47. package/cjs/test_utils.d.ts +10 -0
  48. package/cjs/test_utils.d.ts.map +1 -0
  49. package/cjs/test_utils.js +25 -0
  50. package/cjs/test_utils.js.map +1 -0
  51. package/cjs/testing/index.d.ts +2 -0
  52. package/cjs/testing/index.d.ts.map +1 -0
  53. package/cjs/testing/index.js +6 -0
  54. package/cjs/testing/index.js.map +1 -0
  55. package/cjs/types.d.ts +12 -12
  56. package/cjs/types.d.ts.map +1 -1
  57. package/cjs/types.js.map +1 -1
  58. package/dist/standard-log.es5.js +1139 -758
  59. package/dist/standard-log.es5.js.gz +0 -0
  60. package/dist/standard-log.es5.js.map +1 -1
  61. package/dist/standard-log.es5.js.map.gz +0 -0
  62. package/dist/standard-log.esm.js +220 -175
  63. package/dist/standard-log.esm.js.gz +0 -0
  64. package/dist/standard-log.esm.js.map +1 -1
  65. package/dist/standard-log.esm.js.map.gz +0 -0
  66. package/esm/console.d.ts +3 -3
  67. package/esm/console.d.ts.map +1 -1
  68. package/esm/console.js +21 -10
  69. package/esm/console.js.map +1 -1
  70. package/esm/errors.d.ts.map +1 -1
  71. package/esm/errors.js.map +1 -1
  72. package/esm/formatter.d.ts +1 -1
  73. package/esm/formatter.d.ts.map +1 -1
  74. package/esm/formatter.js +1 -1
  75. package/esm/formatter.js.map +1 -1
  76. package/esm/index.d.ts +4 -4
  77. package/esm/index.d.ts.map +1 -1
  78. package/esm/index.js +2 -2
  79. package/esm/index.js.map +1 -1
  80. package/esm/{logLevels.d.ts → log_levels.d.ts} +1 -1
  81. package/esm/log_levels.d.ts.map +1 -0
  82. package/esm/{logLevels.js → log_levels.js} +1 -1
  83. package/esm/log_levels.js.map +1 -0
  84. package/{cjs/logStore.d.ts → esm/log_store.d.ts} +1 -1
  85. package/esm/log_store.d.ts.map +1 -0
  86. package/esm/{logStore.js → log_store.js} +2 -2
  87. package/esm/log_store.js.map +1 -0
  88. package/esm/logger.d.ts +1 -1
  89. package/esm/logger.d.ts.map +1 -1
  90. package/esm/logger.js +2 -2
  91. package/esm/logger.js.map +1 -1
  92. package/esm/memory.d.ts +2 -2
  93. package/esm/memory.d.ts.map +1 -1
  94. package/esm/memory.js +15 -8
  95. package/esm/memory.js.map +1 -1
  96. package/esm/platform.d.ts.map +1 -1
  97. package/esm/platform.js +1 -2
  98. package/esm/platform.js.map +1 -1
  99. package/esm/{standardLog.ctx.d.ts → standard_log.ctx.d.ts} +2 -2
  100. package/esm/standard_log.ctx.d.ts.map +1 -0
  101. package/esm/{standardLog.ctx.js → standard_log.ctx.js} +1 -1
  102. package/esm/standard_log.ctx.js.map +1 -0
  103. package/{cjs/standardLog.d.ts → esm/standard_log.d.ts} +4 -9
  104. package/esm/standard_log.d.ts.map +1 -0
  105. package/esm/{standardLog.js → standard_log.js} +27 -28
  106. package/esm/standard_log.js.map +1 -0
  107. package/esm/standard_log.mocks.d.ts +8 -0
  108. package/esm/standard_log.mocks.d.ts.map +1 -0
  109. package/esm/standard_log.mocks.js +16 -0
  110. package/esm/standard_log.mocks.js.map +1 -0
  111. package/esm/test_utils.d.ts +10 -0
  112. package/esm/test_utils.d.ts.map +1 -0
  113. package/esm/test_utils.js +18 -0
  114. package/esm/test_utils.js.map +1 -0
  115. package/esm/testing/index.d.ts +2 -0
  116. package/esm/testing/index.d.ts.map +1 -0
  117. package/esm/testing/index.js +2 -0
  118. package/esm/testing/index.js.map +1 -0
  119. package/esm/types.d.ts +12 -12
  120. package/esm/types.d.ts.map +1 -1
  121. package/esm/types.js.map +1 -1
  122. package/package.json +14 -8
  123. package/ts/console.ts +55 -46
  124. package/ts/errors.ts +6 -6
  125. package/ts/formatter.ts +19 -19
  126. package/ts/index.ts +19 -10
  127. package/ts/log_levels.ts +107 -0
  128. package/ts/log_store.ts +63 -0
  129. package/ts/logger.ts +69 -59
  130. package/ts/memory.ts +66 -54
  131. package/ts/platform.ts +2 -2
  132. package/ts/standard_log.ctx.ts +8 -0
  133. package/ts/standard_log.mocks.ts +22 -0
  134. package/ts/standard_log.ts +140 -0
  135. package/ts/test_utils.ts +21 -0
  136. package/ts/testing/index.ts +1 -0
  137. package/ts/types.ts +72 -62
  138. package/cjs/logLevels.d.ts.map +0 -1
  139. package/cjs/logLevels.js.map +0 -1
  140. package/cjs/logStore.d.ts.map +0 -1
  141. package/cjs/logStore.js.map +0 -1
  142. package/cjs/standardLog.ctx.d.ts.map +0 -1
  143. package/cjs/standardLog.ctx.js.map +0 -1
  144. package/cjs/standardLog.d.ts.map +0 -1
  145. package/cjs/standardLog.js.map +0 -1
  146. package/esm/logLevels.d.ts.map +0 -1
  147. package/esm/logLevels.js.map +0 -1
  148. package/esm/logStore.d.ts.map +0 -1
  149. package/esm/logStore.js.map +0 -1
  150. package/esm/standardLog.ctx.d.ts.map +0 -1
  151. package/esm/standardLog.ctx.js.map +0 -1
  152. package/esm/standardLog.d.ts.map +0 -1
  153. package/esm/standardLog.js.map +0 -1
  154. package/ts/logLevels.ts +0 -108
  155. package/ts/logStore.ts +0 -54
  156. package/ts/standardLog.ctx.ts +0 -8
  157. package/ts/standardLog.ts +0 -135
@@ -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,15 +7,11 @@ export declare function createStandardLogClosure<N extends string = LogMethodNam
8
7
  store: LogStore;
9
8
  standardLog: StandardLog<N>;
10
9
  };
11
- export declare 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
  */
18
13
  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>;
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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AAkB,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,15 +33,19 @@ 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
40
- .concat(Object.keys((_c = options === null || options === void 0 ? void 0 : options.customLevels) !== null && _c !== void 0 ? _c : {}))
41
- .concat(['on', 'count', 'write']);
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([
39
+ 'on',
40
+ 'count',
41
+ 'write'
42
+ ]);
42
43
  return {
43
44
  store: store,
44
45
  standardLog: {
45
- get logLevel() { return store.logLevel; },
46
+ get logLevel() {
47
+ return store.logLevel;
48
+ },
46
49
  toLogLevelName: function (level) {
47
50
  return store.logLevelStore.getName(level);
48
51
  },
@@ -52,7 +55,7 @@ function createStandardLogClosure(options) {
52
55
  getLogger: function (id, options) {
53
56
  if (store.loggers[id])
54
57
  return store.loggers[id];
55
- return store.loggers[id] = (0, logger_js_1.createLogger)(store, id, __assign({ ssf: this.getLogger }, options));
58
+ return (store.loggers[id] = (0, logger_js_1.createLogger)(store, id, __assign({ ssf: this.getLogger }, options)));
56
59
  },
57
60
  getNonConsoleLogger: function (id, options) {
58
61
  if (store.nonConsoleLoggers[id])
@@ -60,14 +63,15 @@ function createStandardLogClosure(options) {
60
63
  if (store.loggers[id]) {
61
64
  var log = this.getLogger('standard-log');
62
65
  log.warn("attempt to create a non-console logger with existing id ('".concat(id, "'), ignoring"));
63
- return store.nonConsoleLoggers[id] = createDummyLogger(logMethods);
66
+ return (store.nonConsoleLoggers[id] = createDummyLogger(logMethods));
64
67
  }
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
- },
68
+ return (store.nonConsoleLoggers[id] =
69
+ nonConsoleReporters.length === 0
70
+ ? createDummyLogger(logMethods)
71
+ : (0, logger_js_1.createLogger)(store, id, __assign(__assign({ ssf: this.getNonConsoleLogger }, options), { writeTo: function (reporterId) {
72
+ return nonConsoleReporters.indexOf(reporterId) >= 0;
73
+ } })));
74
+ }
71
75
  }
72
76
  };
73
77
  }
@@ -78,22 +82,15 @@ function createDummyLogger(logMethods) {
78
82
  return p;
79
83
  }, (0, type_plus_1.record)());
80
84
  }
81
- function createStandardLogForTest(logLevel) {
82
- if (logLevel === void 0) { logLevel = logLevels_js_1.logLevels.debug; }
83
- var reporter = (0, memory_js_1.createMemoryLogReporter)();
84
- var closure = createStandardLogClosure({ reporters: [reporter], logLevel: logLevel });
85
- return __assign(__assign({}, closure.standardLog), { reporter: reporter });
86
- }
87
- exports.createStandardLogForTest = createStandardLogForTest;
88
85
  function suppressLogs(block) {
89
86
  var logs = [];
90
87
  for (var _i = 1; _i < arguments.length; _i++) {
91
88
  logs[_i - 1] = arguments[_i];
92
89
  }
93
90
  var origLevels = logs.map(function (l) { return l.level; });
94
- 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); });
95
92
  var result = block();
96
- logs.forEach(function (l, i) { return l.level = origLevels[i]; });
93
+ logs.forEach(function (l, i) { return (l.level = origLevels[i]); });
97
94
  return result;
98
95
  }
99
96
  exports.suppressLogs = suppressLogs;
@@ -102,29 +99,29 @@ function getLogger(id, options) {
102
99
  }
103
100
  exports.getLogger = getLogger;
104
101
  function getGlobalSL() {
105
- if (!standardLog_ctx_js_1.ctx.gsl)
106
- standardLog_ctx_js_1.ctx.gsl = createStandardLogClosure();
107
- 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;
108
105
  }
109
106
  function configGlobal(options) {
110
- if (standardLog_ctx_js_1.ctx.configured) {
111
- 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');
112
109
  log.warn('configGlobal() is being called more than once. Please make sure this is expected. Application should use `createStandardLog()` most of the time.');
113
110
  }
114
- if (standardLog_ctx_js_1.ctx.gsl) {
111
+ if (standard_log_ctx_js_1.ctx.gsl) {
115
112
  if (options.logLevel) {
116
- standardLog_ctx_js_1.ctx.gsl.store.logLevel = options.logLevel;
113
+ standard_log_ctx_js_1.ctx.gsl.store.logLevel = options.logLevel;
117
114
  }
118
115
  if (options.reporters) {
119
- var reporters = standardLog_ctx_js_1.ctx.gsl.store.reporters;
116
+ var reporters = standard_log_ctx_js_1.ctx.gsl.store.reporters;
120
117
  reporters.length = 0;
121
118
  reporters.push.apply(reporters, options.reporters);
122
119
  }
123
120
  }
124
121
  else {
125
- standardLog_ctx_js_1.ctx.gsl = createStandardLogClosure(options);
122
+ standard_log_ctx_js_1.ctx.gsl = createStandardLogClosure(options);
126
123
  }
127
- standardLog_ctx_js_1.ctx.configured = true;
124
+ standard_log_ctx_js_1.ctx.configured = true;
128
125
  }
129
126
  exports.configGlobal = configGlobal;
130
- //# sourceMappingURL=standardLog.js.map
127
+ //# sourceMappingURL=standard_log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard_log.js","sourceRoot":"","sources":["../ts/standard_log.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uCAA4C;AAC5C,iDAAqE;AACrE,+CAA8D;AAC9D,yCAA0C;AAC1C,6DAA2C;AAW3C,SAAgB,iBAAiB,CAChC,OAA+B;;IAE/B,IAAM,OAAO,GAA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BAAG,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,10 @@
1
+ /// <reference types="jest" />
2
+ import type { LogEntry } from './types.js';
3
+ export declare function rangeEntries(start: number, end: number, expected: any): any[][];
4
+ export declare function assertSSF(err: Error, filename: string): void;
5
+ export declare function logEntriesToString(logs: LogEntry[]): string;
6
+ export declare function wrapTest<F extends Record<any, any>>(fn: (test: jest.It) => F): F & {
7
+ only: F;
8
+ skip: F;
9
+ };
10
+ //# sourceMappingURL=test_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_utils.d.ts","sourceRoot":"","sources":["../ts/test_utils.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,WAErE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,QAGrD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,UAElD;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC;;;EAE5E"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapTest = exports.logEntriesToString = exports.assertSSF = exports.rangeEntries = void 0;
4
+ var ramda_1 = require("ramda");
5
+ var formatter_js_1 = require("./formatter.js");
6
+ var platform_js_1 = require("./platform.js");
7
+ function rangeEntries(start, end, expected) {
8
+ return (0, ramda_1.range)(start, end).map(function (value) { return [value, expected]; });
9
+ }
10
+ exports.rangeEntries = rangeEntries;
11
+ function assertSSF(err, filename) {
12
+ var _a;
13
+ var firstStackTrace = (_a = err.stack) === null || _a === void 0 ? void 0 : _a.split('\n')[1];
14
+ expect(firstStackTrace).toMatch(filename);
15
+ }
16
+ exports.assertSSF = assertSSF;
17
+ function logEntriesToString(logs) {
18
+ return logs.map(platform_js_1.toInspectLogEntry).map(formatter_js_1.plainLogFormatter).join('\n');
19
+ }
20
+ exports.logEntriesToString = logEntriesToString;
21
+ function wrapTest(fn) {
22
+ return Object.assign(fn(test), { only: fn(test.only), skip: fn(test.skip) });
23
+ }
24
+ exports.wrapTest = wrapTest;
25
+ //# sourceMappingURL=test_utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_utils.js","sourceRoot":"","sources":["../ts/test_utils.ts"],"names":[],"mappings":";;;AAAA,+BAA6B;AAC7B,+CAAkD;AAClD,6CAAiD;AAGjD,SAAgB,YAAY,CAAC,KAAa,EAAE,GAAW,EAAE,QAAa;IACrE,OAAO,IAAA,aAAK,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAjB,CAAiB,CAAC,CAAA;AACzD,CAAC;AAFD,oCAEC;AAED,SAAgB,SAAS,CAAC,GAAU,EAAE,QAAgB;;IACrD,IAAM,eAAe,GAAG,MAAA,GAAG,CAAC,KAAK,0CAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IACjD,MAAM,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;AAC1C,CAAC;AAHD,8BAGC;AAED,SAAgB,kBAAkB,CAAC,IAAgB;IAClD,OAAO,IAAI,CAAC,GAAG,CAAC,+BAAiB,CAAC,CAAC,GAAG,CAAC,gCAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACrE,CAAC;AAFD,gDAEC;AAED,SAAgB,QAAQ,CAA6B,EAAwB;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC7E,CAAC;AAFD,4BAEC","sourcesContent":["import { range } from 'ramda'\nimport { plainLogFormatter } from './formatter.js'\nimport { toInspectLogEntry } from './platform.js'\nimport type { LogEntry } from './types.js'\n\nexport function rangeEntries(start: number, end: number, expected: any) {\n\treturn range(start, end).map(value => [value, expected])\n}\n\nexport function assertSSF(err: Error, filename: string) {\n\tconst firstStackTrace = err.stack?.split('\\n')[1]\n\texpect(firstStackTrace).toMatch(filename)\n}\n\nexport function logEntriesToString(logs: LogEntry[]) {\n\treturn logs.map(toInspectLogEntry).map(plainLogFormatter).join('\\n')\n}\n\nexport function wrapTest<F extends Record<any, any>>(fn: (test: jest.It) => F) {\n\treturn Object.assign(fn(test), { only: fn(test.only), skip: fn(test.skip) })\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"]}
package/cjs/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { StackTraceMeta } from '@just-func/types';
2
- export declare type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
2
+ export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
3
3
  customLevels?: Record<CustomLevelNames, number>;
4
4
  logLevel?: number;
5
5
  reporters?: LogReporter[];
@@ -8,7 +8,7 @@ export interface LoggerOptions extends StackTraceMeta {
8
8
  level?: number;
9
9
  writeTo?: LogReporter | ReporterFilter;
10
10
  }
11
- export declare type Logger<N extends string = LogMethodNames> = {
11
+ export type Logger<N extends string = LogMethodNames> = {
12
12
  readonly id: string;
13
13
  /**
14
14
  * Logger local log level.
@@ -30,16 +30,16 @@ export declare type Logger<N extends string = LogMethodNames> = {
30
30
  /**
31
31
  * Names of the standard log methods.
32
32
  */
33
- export declare type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
34
- export declare type LogEntry = {
33
+ export type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
34
+ export type LogEntry = {
35
35
  id: string;
36
36
  level: number;
37
37
  args: any[];
38
38
  timestamp: Date;
39
39
  };
40
- export declare type LogMethod = (...args: any[]) => void;
41
- export declare type LogFunction = (log: LogMethod, logLevel: number) => string | void;
42
- export declare type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
40
+ export type LogMethod = (...args: any[]) => void;
41
+ export type LogFunction = (log: LogMethod, logLevel: number) => string | void;
42
+ export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
43
43
  export interface StandardLogInstance<N extends string = LogMethodNames> {
44
44
  logLevel: number;
45
45
  toLogLevelName(level: number): string;
@@ -52,12 +52,12 @@ export interface StandardLogInstance<N extends string = LogMethodNames> {
52
52
  * Depends on the reporter, it can expect a different return type.
53
53
  * By default the return type is `any[]` which the `console` accepts.
54
54
  */
55
- export declare type LogFormatter<T = any[]> = (entry: LogEntry) => T;
55
+ export type LogFormatter<T = any[]> = (entry: LogEntry) => T;
56
56
  /**
57
57
  * Determines whether the entry should be written.
58
58
  */
59
- export declare type LogFilter = (entry: LogEntry) => boolean;
60
- export declare type LogLevelEntry = {
59
+ export type LogFilter = (entry: LogEntry) => boolean;
60
+ export type LogLevelEntry = {
61
61
  name: string;
62
62
  level: number;
63
63
  };
@@ -79,7 +79,7 @@ export interface LogReporter<T = any> {
79
79
  readonly isConsoleReporter?: boolean;
80
80
  write(entry: LogEntry): void;
81
81
  }
82
- export declare type LogReporterOptions<T = any> = {
82
+ export type LogReporterOptions<T = any> = {
83
83
  id?: string;
84
84
  /**
85
85
  * Specifies the formatter to be used by the reporter.
@@ -91,7 +91,7 @@ export declare type LogReporterOptions<T = any> = {
91
91
  */
92
92
  filter?: LogFilter;
93
93
  };
94
- export declare type LogLevel = number;
94
+ export type LogLevel = number;
95
95
  export interface ConsoleLike {
96
96
  debug(...args: any[]): void;
97
97
  info(...args: any[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,oBAAY,kBAAkB,CAAC,gBAAgB,SAAS,MAAM,GAAG,cAAc,IAAI;IACjF,YAAY,CAAC,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,WAAW,EAAE,CAAA;CAC1B,CAAA;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CAAA;CACvC;AAED,oBAAY,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,cAAc,IAAI;IACtD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5B,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IACtD;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,Q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,CAAC,EAAE,OAAO,CAAA;IACpC,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;CAC5B;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,GAAG,IAAI;IACzC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAA;AAE7B,MAAM,WAAW,WAAW;IAC3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAC1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;CAC3B"}
package/cjs/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StackTraceMeta } from '@just-func/types'\n\nexport type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {\n customLevels?: Record<CustomLevelNames, number>,\n logLevel?: number,\n reporters?: LogReporter[]\n}\n\nexport interface LoggerOptions extends StackTraceMeta {\n level?: number,\n writeTo?: LogReporter | ReporterFilter\n}\n\nexport type Logger<N extends string = LogMethodNames> = {\n readonly id: string,\n /**\n * Logger local log level.\n */\n level?: number,\n /**\n * Logs with an increment counter.\n * This is useful during debugging to check for steps executed.\n */\n count(...args: any[]): void,\n on(level: number | N, logFunction: LogFunction): void,\n /**\n * Write custom log entries.\n */\n write(entry: LogEntry): void\n} & { [k in N]: LogMethod }\n\n/**\n * Names of the standard log methods.\n */\nexport type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck'\n\nexport type LogEntry = {\n id: string,\n level: number,\n // args instead of messages because it is `any[]` instead of `string[]`\n args: any[],\n timestamp: Date\n}\n\nexport type LogMethod = (...args: any[]) => void\n\nexport type LogFunction = (log: LogMethod, logLevel: number) => string | void\n\nexport type ReporterFilter = string | RegExp | ((reporterId: string) => boolean)\n\nexport interface StandardLogInstance<N extends string = LogMethodNames> {\n logLevel: number,\n toLogLevelName(level: number): string,\n toLogLevel(name: N): number,\n getLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>,\n getNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n}\n\n/**\n * Formats a log entry.\n * Depends on the reporter, it can expect a different return type.\n * By default the return type is `any[]` which the `console` accepts.\n */\nexport type LogFormatter<T = any[]> = (entry: LogEntry) => T\n\n/**\n * Determines whether the entry should be written.\n */\nexport type LogFilter = (entry: LogEntry) => boolean\n\nexport type LogLevelEntry = { name: string, level: number }\n\nexport interface LogReporter<T = any> {\n readonly id: string,\n /**\n * Specifies the formatter to be used by the reporter.\n * Using this you can customize how the reporter writes the log entry.\n */\n readonly formatter: LogFormatter<T>,\n /**\n * Specifies a filter to determine should the log be written.\n */\n readonly filter?: LogFilter,\n /**\n * Indicate if this is a console reporter.\n * There is only one console reporter can be present in the system.\n */\n readonly isConsoleReporter?: boolean,\n write(entry: LogEntry): void\n}\n\nexport type LogReporterOptions<T = any> = {\n id?: string,\n /**\n * Specifies the formatter to be used by the reporter.\n * Using this you can customize how the reporter writes the log entry.\n */\n formatter?: LogFormatter<T>,\n /**\n * Specifies a filter to determine should the log be written.\n */\n filter?: LogFilter\n}\n\nexport type LogLevel = number\n\nexport interface ConsoleLike {\n debug(...args: any[]): void,\n info(...args: any[]): void,\n warn(...args: any[]): void,\n error(...args: any[]): void,\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../ts/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StackTraceMeta } from '@just-func/types'\n\nexport type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {\n\tcustomLevels?: Record<CustomLevelNames, number>\n\tlogLevel?: number\n\treporters?: LogReporter[]\n}\n\nexport interface LoggerOptions extends StackTraceMeta {\n\tlevel?: number\n\twriteTo?: LogReporter | ReporterFilter\n}\n\nexport type Logger<N extends string = LogMethodNames> = {\n\treadonly id: string\n\t/**\n\t * Logger local log level.\n\t */\n\tlevel?: number\n\t/**\n\t * Logs with an increment counter.\n\t * This is useful during debugging to check for steps executed.\n\t */\n\tcount(...args: any[]): void\n\ton(level: number | N, logFunction: LogFunction): void\n\t/**\n\t * Write custom log entries.\n\t */\n\twrite(entry: LogEntry): void\n} & { [k in N]: LogMethod }\n\n/**\n * Names of the standard log methods.\n */\nexport type LogMethodNames =\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\nexport type LogEntry = {\n\tid: string\n\tlevel: number\n\t// args instead of messages because it is `any[]` instead of `string[]`\n\targs: any[]\n\ttimestamp: Date\n}\n\nexport type LogMethod = (...args: any[]) => void\n\nexport type LogFunction = (log: LogMethod, logLevel: number) => string | void\n\nexport type ReporterFilter = string | RegExp | ((reporterId: string) => boolean)\n\nexport interface StandardLogInstance<N extends string = LogMethodNames> {\n\tlogLevel: number\n\ttoLogLevelName(level: number): string\n\ttoLogLevel(name: N): number\n\tgetLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n\tgetNonConsoleLogger(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>\n}\n\n/**\n * Formats a log entry.\n * Depends on the reporter, it can expect a different return type.\n * By default the return type is `any[]` which the `console` accepts.\n */\nexport type LogFormatter<T = any[]> = (entry: LogEntry) => T\n\n/**\n * Determines whether the entry should be written.\n */\nexport type LogFilter = (entry: LogEntry) => boolean\n\nexport type LogLevelEntry = { name: string; level: number }\n\nexport interface LogReporter<T = any> {\n\treadonly id: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\treadonly formatter: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\treadonly filter?: LogFilter\n\t/**\n\t * Indicate if this is a console reporter.\n\t * There is only one console reporter can be present in the system.\n\t */\n\treadonly isConsoleReporter?: boolean\n\twrite(entry: LogEntry): void\n}\n\nexport type LogReporterOptions<T = any> = {\n\tid?: string\n\t/**\n\t * Specifies the formatter to be used by the reporter.\n\t * Using this you can customize how the reporter writes the log entry.\n\t */\n\tformatter?: LogFormatter<T>\n\t/**\n\t * Specifies a filter to determine should the log be written.\n\t */\n\tfilter?: LogFilter\n}\n\nexport type LogLevel = number\n\nexport interface ConsoleLike {\n\tdebug(...args: any[]): void\n\tinfo(...args: any[]): void\n\twarn(...args: any[]): void\n\terror(...args: any[]): void\n}\n"]}