standard-log 13.3.0 → 13.3.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 (102) hide show
  1. package/cjs/console.d.ts +5 -6
  2. package/cjs/console.d.ts.map +1 -1
  3. package/cjs/console.js +2 -2
  4. package/cjs/console.js.map +1 -1
  5. package/cjs/errors.d.ts +2 -3
  6. package/cjs/errors.d.ts.map +1 -1
  7. package/cjs/formatter.d.ts +5 -6
  8. package/cjs/formatter.d.ts.map +1 -1
  9. package/cjs/log_levels.d.ts +4 -5
  10. package/cjs/log_levels.d.ts.map +1 -1
  11. package/cjs/log_store.d.ts +4 -5
  12. package/cjs/log_store.d.ts.map +1 -1
  13. package/cjs/log_store.js +7 -7
  14. package/cjs/log_store.js.map +1 -1
  15. package/cjs/logger.d.ts +1 -2
  16. package/cjs/logger.d.ts.map +1 -1
  17. package/cjs/memory.d.ts +5 -6
  18. package/cjs/memory.d.ts.map +1 -1
  19. package/cjs/memory.js +4 -4
  20. package/cjs/memory.js.map +1 -1
  21. package/cjs/platform.browser.d.ts +2 -3
  22. package/cjs/platform.browser.d.ts.map +1 -1
  23. package/cjs/platform.browser.js +2 -2
  24. package/cjs/platform.browser.js.map +1 -1
  25. package/cjs/platform.d.ts +2 -3
  26. package/cjs/platform.d.ts.map +1 -1
  27. package/cjs/platform.js +2 -2
  28. package/cjs/platform.js.map +1 -1
  29. package/cjs/record.d.ts +9 -0
  30. package/cjs/record.d.ts.map +1 -0
  31. package/cjs/record.js +15 -0
  32. package/cjs/record.js.map +1 -0
  33. package/cjs/standard_log.ctx.d.ts +1 -2
  34. package/cjs/standard_log.ctx.d.ts.map +1 -1
  35. package/cjs/standard_log.ctx.js +1 -1
  36. package/cjs/standard_log.ctx.js.map +1 -1
  37. package/cjs/standard_log.d.ts +7 -8
  38. package/cjs/standard_log.d.ts.map +1 -1
  39. package/cjs/standard_log.js +4 -3
  40. package/cjs/standard_log.js.map +1 -1
  41. package/cjs/standard_log.testing.d.ts +3 -4
  42. package/cjs/standard_log.testing.d.ts.map +1 -1
  43. package/cjs/types.d.ts +20 -18
  44. package/cjs/types.d.ts.map +1 -1
  45. package/dist/standard-log.esm.js +15 -31
  46. package/dist/standard-log.esm.js.map +1 -1
  47. package/dist/standard-log.iife.js +15 -31
  48. package/dist/standard-log.iife.js.map +1 -1
  49. package/esm/console.d.ts +5 -6
  50. package/esm/console.d.ts.map +1 -1
  51. package/esm/console.js +1 -1
  52. package/esm/console.js.map +1 -1
  53. package/esm/errors.d.ts +2 -3
  54. package/esm/errors.d.ts.map +1 -1
  55. package/esm/formatter.d.ts +5 -6
  56. package/esm/formatter.d.ts.map +1 -1
  57. package/esm/log_levels.d.ts +4 -5
  58. package/esm/log_levels.d.ts.map +1 -1
  59. package/esm/log_store.d.ts +4 -5
  60. package/esm/log_store.d.ts.map +1 -1
  61. package/esm/log_store.js +4 -4
  62. package/esm/log_store.js.map +1 -1
  63. package/esm/logger.d.ts +1 -2
  64. package/esm/logger.d.ts.map +1 -1
  65. package/esm/memory.d.ts +5 -6
  66. package/esm/memory.d.ts.map +1 -1
  67. package/esm/memory.js +1 -1
  68. package/esm/memory.js.map +1 -1
  69. package/esm/platform.browser.d.ts +2 -3
  70. package/esm/platform.browser.d.ts.map +1 -1
  71. package/esm/platform.browser.js +1 -1
  72. package/esm/platform.browser.js.map +1 -1
  73. package/esm/platform.d.ts +2 -3
  74. package/esm/platform.d.ts.map +1 -1
  75. package/esm/platform.js +1 -1
  76. package/esm/platform.js.map +1 -1
  77. package/esm/record.d.ts +9 -0
  78. package/esm/record.d.ts.map +1 -0
  79. package/esm/record.js +14 -0
  80. package/esm/record.js.map +1 -0
  81. package/esm/standard_log.ctx.d.ts +1 -2
  82. package/esm/standard_log.ctx.d.ts.map +1 -1
  83. package/esm/standard_log.ctx.js +1 -1
  84. package/esm/standard_log.ctx.js.map +1 -1
  85. package/esm/standard_log.d.ts +7 -8
  86. package/esm/standard_log.d.ts.map +1 -1
  87. package/esm/standard_log.js +2 -1
  88. package/esm/standard_log.js.map +1 -1
  89. package/esm/standard_log.testing.d.ts +3 -4
  90. package/esm/standard_log.testing.d.ts.map +1 -1
  91. package/esm/types.d.ts +20 -18
  92. package/esm/types.d.ts.map +1 -1
  93. package/package.json +7 -7
  94. package/ts/console.ts +1 -1
  95. package/ts/log_store.ts +4 -6
  96. package/ts/memory.ts +1 -1
  97. package/ts/platform.browser.ts +1 -1
  98. package/ts/platform.ts +1 -1
  99. package/ts/record.ts +9 -0
  100. package/ts/standard_log.ctx.ts +1 -1
  101. package/ts/standard_log.ts +2 -1
  102. package/ts/types.ts +5 -3
package/esm/platform.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { ConsoleLike, LogEntry } from "./types.js";
2
2
  //#region ts/platform.d.ts
3
- declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
4
- declare const polyfill: {
3
+ export declare const toInspectLogEntry: (e: LogEntry) => LogEntry;
4
+ export declare const polyfill: {
5
5
  console?: ConsoleLike;
6
6
  };
7
7
  //#endregion
8
- export { polyfill, toInspectLogEntry };
9
8
  //# sourceMappingURL=platform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","names":[],"sources":["../ts/platform.ts"],"mappings":";;cAIa,oBAAiB,GAAO,aAAQ;cAIhC;EAAY,UAAU"}
1
+ {"version":3,"file":"platform.d.ts","names":[],"sources":["../ts/platform.ts"],"mappings":";;qBAIa,oBAAiB,GAAO,aAAQ;qBAIhC;EAAY,UAAU"}
package/esm/platform.js CHANGED
@@ -1,4 +1,4 @@
1
- import { record } from "type-plus";
1
+ import { record } from "./record.js";
2
2
  import { inspect } from "node:util";
3
3
  //#region ts/platform.ts
4
4
  const toInspectLogEntry = (e) => (e.args = e.args.map((value) => typeof value === "object" && value !== null ? inspect(value) : value), e);
@@ -1 +1 @@
1
- {"version":3,"file":"platform.js","names":[],"sources":["../ts/platform.ts"],"sourcesContent":["import { inspect } from 'node:util'\nimport { record } from 'type-plus'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => (\n\t(e.args = e.args.map(value => (typeof value === 'object' && value !== null ? inspect(value) : value))), e\n)\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"],"mappings":";;;AAIA,MAAa,qBAAqB,OAChC,EAAE,OAAO,EAAE,KAAK,KAAI,UAAU,OAAO,UAAU,YAAY,UAAU,OAAO,QAAQ,KAAK,IAAI,KAAM,GAAI;AAGzG,MAAa,WAAsC,OAAO"}
1
+ {"version":3,"file":"platform.js","names":[],"sources":["../ts/platform.ts"],"sourcesContent":["import { inspect } from 'node:util'\nimport { record } from './record.js'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => (\n\t(e.args = e.args.map(value => (typeof value === 'object' && value !== null ? inspect(value) : value))), e\n)\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"],"mappings":";;;AAIA,MAAa,qBAAqB,OAChC,EAAE,OAAO,EAAE,KAAK,KAAI,UAAU,OAAO,UAAU,YAAY,UAAU,OAAO,QAAQ,KAAK,IAAI,KAAM,GAAI;AAGzG,MAAa,WAAsC,OAAO"}
@@ -0,0 +1,9 @@
1
+ //#region ts/record.d.ts
2
+ /**
3
+ * Creates a prototype-less object, optionally seeded with `value`.
4
+ *
5
+ * Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.
6
+ */
7
+ export declare function record<R extends Record<any, any>>(value?: R): R;
8
+ //#endregion
9
+ //# sourceMappingURL=record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.d.ts","names":[],"sources":["../ts/record.ts"],"mappings":";;;;;;wBAKgB,OAAO,UAAU,kBAAkB,QAAQ,IAAI"}
package/esm/record.js ADDED
@@ -0,0 +1,14 @@
1
+ //#region ts/record.ts
2
+ /**
3
+ * Creates a prototype-less object, optionally seeded with `value`.
4
+ *
5
+ * Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.
6
+ */
7
+ function record(value) {
8
+ const r = Object.create(null);
9
+ return value ? Object.assign(r, value) : r;
10
+ }
11
+ //#endregion
12
+ export { record };
13
+
14
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","names":[],"sources":["../ts/record.ts"],"sourcesContent":["/**\n * Creates a prototype-less object, optionally seeded with `value`.\n *\n * Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.\n */\nexport function record<R extends Record<any, any>>(value?: R): R {\n\tconst r = Object.create(null)\n\treturn value ? Object.assign(r, value) : r\n}\n"],"mappings":";;;;;;AAKA,SAAgB,OAAmC,OAAc;CAChE,MAAM,IAAI,OAAO,OAAO,IAAI;CAC5B,OAAO,QAAQ,OAAO,OAAO,GAAG,KAAK,IAAI;AAC1C"}
@@ -1,7 +1,7 @@
1
1
  import { LogMethodNames, StandardLogInstance } from "./types.js";
2
2
  import { LogStore } from "./log_store.js";
3
3
  //#region ts/standard_log.ctx.d.ts
4
- declare const ctx: {
4
+ export declare const ctx: {
5
5
  configured?: boolean;
6
6
  gsl?: {
7
7
  store: LogStore;
@@ -9,5 +9,4 @@ declare const ctx: {
9
9
  };
10
10
  };
11
11
  //#endregion
12
- export { ctx };
13
12
  //# sourceMappingURL=standard_log.ctx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard_log.ctx.d.ts","names":[],"sources":["../ts/standard_log.ctx.ts"],"mappings":";;;cAIa;EACZ;EACA;IAAQ,OAAO;IAAU,aAAa,oBAAoB"}
1
+ {"version":3,"file":"standard_log.ctx.d.ts","names":[],"sources":["../ts/standard_log.ctx.ts"],"mappings":";;;qBAIa;EACZ;EACA;IAAQ,OAAO;IAAU,aAAa,oBAAoB"}
@@ -1,4 +1,4 @@
1
- import { record } from "type-plus";
1
+ import { record } from "./record.js";
2
2
  //#region ts/standard_log.ctx.ts
3
3
  const ctx = record();
4
4
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"standard_log.ctx.js","names":[],"sources":["../ts/standard_log.ctx.ts"],"sourcesContent":["import { record } from 'type-plus'\nimport type { LogStore } from './log_store.js'\nimport type { LogMethodNames, StandardLogInstance } from './types.js'\n\nexport const ctx: {\n\tconfigured?: boolean\n\tgsl?: { store: LogStore; standardLog: StandardLogInstance<LogMethodNames> }\n} = record()\n"],"mappings":";;AAIA,MAAa,MAGT,OAAO"}
1
+ {"version":3,"file":"standard_log.ctx.js","names":[],"sources":["../ts/standard_log.ctx.ts"],"sourcesContent":["import type { LogStore } from './log_store.js'\nimport { record } from './record.js'\nimport type { LogMethodNames, StandardLogInstance } from './types.js'\n\nexport const ctx: {\n\tconfigured?: boolean\n\tgsl?: { store: LogStore; standardLog: StandardLogInstance<LogMethodNames> }\n} = record()\n"],"mappings":";;AAIA,MAAa,MAGT,OAAO"}
@@ -1,19 +1,18 @@
1
1
  import { LogMethodNames, Logger, LoggerOptions, StandardLogInstance, StandardLogOptions } from "./types.js";
2
2
  import { LogStore } from "./log_store.js";
3
3
  //#region ts/standard_log.d.ts
4
- interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {}
5
- declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
6
- declare function createStandardLogClosure<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): {
4
+ export interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {}
5
+ export declare function createStandardLog<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): StandardLog<N>;
6
+ export declare function createStandardLogClosure<N extends string = LogMethodNames>(options?: StandardLogOptions<N>): {
7
7
  store: LogStore;
8
8
  standardLog: StandardLog<N>;
9
9
  };
10
10
  /**
11
11
  * Suppress logging within the code block.
12
12
  */
13
- declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
14
- type GetLogger<N extends string = LogMethodNames> = (id: string, options?: LoggerOptions) => Logger<LogMethodNames | N>;
15
- declare function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
16
- declare function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>): void;
13
+ export declare function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R;
14
+ export type GetLogger<N extends string = LogMethodNames> = (id: string, options?: LoggerOptions) => Logger<LogMethodNames | N>;
15
+ export declare function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
16
+ export declare function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>): void;
17
17
  //#endregion
18
- export { GetLogger, StandardLog, configGlobal, createStandardLog, createStandardLogClosure, getLogger, suppressLogs };
19
18
  //# sourceMappingURL=standard_log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard_log.d.ts","names":[],"sources":["../ts/standard_log.ts"],"mappings":";;;UAaiB,YAAY,mBAAmB,wBAAwB,SAAS,oBAAoB;iBAErF,kBAAkB,mBAAmB,gBACpD,UAAU,mBAAmB,KAC3B,YAAY;iBAeC,yBAAyB,mBAAmB,gBAC3D,UAAU,mBAAmB;EACzB,OAAO;EAAU,aAAa,YAAY;;;;;iBA4D/B,aAAa,GAAG,aAAa,GAAG,KAAK,WAAW,MAAM,WAAW;KASrE,UAAU,mBAAmB,mBACxC,YACA,UAAU,kBACN,OAAO,iBAAiB;iBAEb,UAAU,mBAAmB,gBAAgB,YAAY,UAAU,gBAAa,OAAA,IAAA;iBAUhF,aAAa,SAAS,KAAK"}
1
+ {"version":3,"file":"standard_log.d.ts","names":[],"sources":["../ts/standard_log.ts"],"mappings":";;;iBAciB,YAAY,mBAAmB,wBAAwB,SAAS,oBAAoB;wBAErF,kBAAkB,mBAAmB,gBACpD,UAAU,mBAAmB,KAC3B,YAAY;wBAeC,yBAAyB,mBAAmB,gBAC3D,UAAU,mBAAmB;EACzB,OAAO;EAAU,aAAa,YAAY;;;;;wBA4D/B,aAAa,GAAG,aAAa,GAAG,KAAK,WAAW,MAAM,WAAW;YASrE,UAAU,mBAAmB,mBACxC,YACA,UAAU,kBACN,OAAO,iBAAiB;wBAEb,UAAU,mBAAmB,gBAAgB,YAAY,UAAU,gBAAa,OAAA,IAAA;wBAUhF,aAAa,SAAS,KAAK"}
@@ -1,8 +1,9 @@
1
1
  import { DEFAULT_LOG_METHOD_NAMES, logLevels } from "./log_levels.js";
2
+ import { record } from "./record.js";
2
3
  import { createLogStore } from "./log_store.js";
3
4
  import { createLogger } from "./logger.js";
4
5
  import { ctx } from "./standard_log.ctx.js";
5
- import { record, required } from "type-plus";
6
+ import { required } from "unpartial";
6
7
  //#region ts/standard_log.ts
7
8
  function createStandardLog(options) {
8
9
  const closure = createStandardLogClosure(options);
@@ -1 +1 @@
1
- {"version":3,"file":"standard_log.js","names":[],"sources":["../ts/standard_log.ts"],"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\tLogger,\n\tLoggerOptions,\n\tLogMethodNames,\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\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"],"mappings":";;;;;;AAeA,SAAgB,kBACf,SACiB;CACjB,MAAM,UAAU,yBAAyB,OAAO;CAChD,IAAI,SAAS,WAAW,MAAK,MAAK,CAAC,EAAE,EAAE,GAEtC,QADoB,YAAY,UAAU,cACxC,CAAC,CAAC,SACH,+JACD;CAGD,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM;CACxB,OAAO,QAAQ;AAChB;AAEA,SAAS,OAAO,CAAC;AAEjB,SAAgB,yBACf,SACmD;CAEnD,MAAM,QAAQ,eAAe,SAAS,EAAE,UAAU,UAAU,KAAK,GAAG,OAAO,CAAC;CAC5E,MAAM,sBAAsB,SAAS,WAAW,QAAO,MAAK,CAAC,EAAE,iBAAiB,CAAC,CAAC,KAAI,MAAK,EAAE,EAAE,KAAK,CAAC;CACrG,MAAM,aAAa,yBAAyB,OAAO,OAAO,KAAK,SAAS,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;EACnG;EACA;EACA;CACD,CAAC;CACD,OAAO;EACN;EACA,aAAa;GACZ,IAAI,WAAW;IACd,OAAO,MAAM;GACd;GAEA,eAAe,OAAe;IAC7B,OAAO,MAAM,cAAc,QAAQ,KAAK;GACzC;GACA,WAAW,MAAc;IACxB,OAAO,MAAM,cAAc,SAAS,IAAI;GACzC;GACA,UAAU,IAAY,SAAyB;IAC9C,IAAI,MAAM,QAAQ,KAAK,OAAO,MAAM,QAAQ;IAC5C,OAAQ,MAAM,QAAQ,MAAM,aAAa,OAAO,IAAI;KAAE,KAAK,KAAK;KAAW,GAAG;IAAQ,CAAC;GACxF;GACA,oBAAoB,IAAI,SAAU;IACjC,IAAI,MAAM,kBAAkB,KAAK,OAAO,MAAM,kBAAkB;IAEhE,IAAI,MAAM,QAAQ,KAAK;KAEtB,KADiB,UAAU,cACzB,CAAC,CAAC,KAAK,6DAA6D,GAAG,aAAa;KACtF,OAAQ,MAAM,kBAAkB,MAAM,kBAAkB,UAAU;IACnE;IAEA,OAAQ,MAAM,kBAAkB,MAC/B,oBAAoB,WAAW,IAC5B,kBAAkB,UAAU,IAC5B,aAAa,OAAO,IAAI;KACxB,KAAK,KAAK;KACV,GAAG;KACH,QAAQ,YAAY;MACnB,OAAO,oBAAoB,QAAQ,UAAU,KAAK;KACnD;IACD,CAAC;GACL;EACD;CACD;AACD;AAEA,SAAS,kBAAkB,YAAsB;CAChD,OAAO,WAAW,QAAQ,GAAG,MAAM;EAClC,EAAE,KAAK;EACP,OAAO;CACR,GAAG,OAAO,CAAC;AACZ;AAMA,SAAgB,aAAgB,OAAgB,GAAG,MAAmB;CACrE,MAAM,aAAa,KAAK,KAAI,MAAK,EAAE,KAAK;CACxC,KAAK,SAAQ,MAAM,EAAE,QAAQ,UAAU,IAAK;CAC5C,MAAM,SAAS,MAAM;CACrB,KAAK,SAAS,GAAG,MAAO,EAAE,QAAQ,WAAW,EAAG;CAChD,OAAO;AACR;AAOA,SAAgB,UAA6C,IAAY,SAAyB;CACjG,OAAO,YAAe,CAAC,CAAC,UAAU,IAAI,OAAO;AAC9C;AAEA,SAAS,cAAyE;CACjF,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,yBAAyB;CAEjD,OAAO,IAAI,IAAK;AACjB;AAEA,SAAgB,aAAa,SAAmD;CAC/E,IAAI,IAAI,YAEP,IADgB,IAAK,YAAY,UAAU,cACzC,CAAC,CAAC,KACH,kJACD;CAGD,IAAI,IAAI,KAAK;EACZ,IAAI,QAAQ,UACX,IAAI,IAAI,MAAM,WAAW,QAAQ;EAElC,IAAI,QAAQ,WAAW;GACtB,MAAM,YAAY,IAAI,IAAI,MAAM;GAChC,UAAU,SAAS;GACnB,UAAU,KAAK,GAAG,QAAQ,SAAS;EACpC;CACD,OACC,IAAI,MAAM,yBAAyB,OAAO;CAE3C,IAAI,aAAa;AAClB"}
1
+ {"version":3,"file":"standard_log.js","names":[],"sources":["../ts/standard_log.ts"],"sourcesContent":["import { required } from 'unpartial'\nimport { DEFAULT_LOG_METHOD_NAMES, logLevels } from './log_levels.js'\nimport { createLogStore, type LogStore } from './log_store.js'\nimport { createLogger } from './logger.js'\nimport { record } from './record.js'\nimport { ctx } from './standard_log.ctx.js'\nimport type {\n\tLogger,\n\tLoggerOptions,\n\tLogMethodNames,\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\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"],"mappings":";;;;;;;AAgBA,SAAgB,kBACf,SACiB;CACjB,MAAM,UAAU,yBAAyB,OAAO;CAChD,IAAI,SAAS,WAAW,MAAK,MAAK,CAAC,EAAE,EAAE,GAEtC,QADoB,YAAY,UAAU,cACxC,CAAC,CAAC,SACH,+JACD;CAGD,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM;CACxB,OAAO,QAAQ;AAChB;AAEA,SAAS,OAAO,CAAC;AAEjB,SAAgB,yBACf,SACmD;CAEnD,MAAM,QAAQ,eAAe,SAAS,EAAE,UAAU,UAAU,KAAK,GAAG,OAAO,CAAC;CAC5E,MAAM,sBAAsB,SAAS,WAAW,QAAO,MAAK,CAAC,EAAE,iBAAiB,CAAC,CAAC,KAAI,MAAK,EAAE,EAAE,KAAK,CAAC;CACrG,MAAM,aAAa,yBAAyB,OAAO,OAAO,KAAK,SAAS,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;EACnG;EACA;EACA;CACD,CAAC;CACD,OAAO;EACN;EACA,aAAa;GACZ,IAAI,WAAW;IACd,OAAO,MAAM;GACd;GAEA,eAAe,OAAe;IAC7B,OAAO,MAAM,cAAc,QAAQ,KAAK;GACzC;GACA,WAAW,MAAc;IACxB,OAAO,MAAM,cAAc,SAAS,IAAI;GACzC;GACA,UAAU,IAAY,SAAyB;IAC9C,IAAI,MAAM,QAAQ,KAAK,OAAO,MAAM,QAAQ;IAC5C,OAAQ,MAAM,QAAQ,MAAM,aAAa,OAAO,IAAI;KAAE,KAAK,KAAK;KAAW,GAAG;IAAQ,CAAC;GACxF;GACA,oBAAoB,IAAI,SAAU;IACjC,IAAI,MAAM,kBAAkB,KAAK,OAAO,MAAM,kBAAkB;IAEhE,IAAI,MAAM,QAAQ,KAAK;KAEtB,KADiB,UAAU,cACzB,CAAC,CAAC,KAAK,6DAA6D,GAAG,aAAa;KACtF,OAAQ,MAAM,kBAAkB,MAAM,kBAAkB,UAAU;IACnE;IAEA,OAAQ,MAAM,kBAAkB,MAC/B,oBAAoB,WAAW,IAC5B,kBAAkB,UAAU,IAC5B,aAAa,OAAO,IAAI;KACxB,KAAK,KAAK;KACV,GAAG;KACH,QAAQ,YAAY;MACnB,OAAO,oBAAoB,QAAQ,UAAU,KAAK;KACnD;IACD,CAAC;GACL;EACD;CACD;AACD;AAEA,SAAS,kBAAkB,YAAsB;CAChD,OAAO,WAAW,QAAQ,GAAG,MAAM;EAClC,EAAE,KAAK;EACP,OAAO;CACR,GAAG,OAAO,CAAC;AACZ;AAMA,SAAgB,aAAgB,OAAgB,GAAG,MAAmB;CACrE,MAAM,aAAa,KAAK,KAAI,MAAK,EAAE,KAAK;CACxC,KAAK,SAAQ,MAAM,EAAE,QAAQ,UAAU,IAAK;CAC5C,MAAM,SAAS,MAAM;CACrB,KAAK,SAAS,GAAG,MAAO,EAAE,QAAQ,WAAW,EAAG;CAChD,OAAO;AACR;AAOA,SAAgB,UAA6C,IAAY,SAAyB;CACjG,OAAO,YAAe,CAAC,CAAC,UAAU,IAAI,OAAO;AAC9C;AAEA,SAAS,cAAyE;CACjF,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,yBAAyB;CAEjD,OAAO,IAAI,IAAK;AACjB;AAEA,SAAgB,aAAa,SAAmD;CAC/E,IAAI,IAAI,YAEP,IADgB,IAAK,YAAY,UAAU,cACzC,CAAC,CAAC,KACH,kJACD;CAGD,IAAI,IAAI,KAAK;EACZ,IAAI,QAAQ,UACX,IAAI,IAAI,MAAM,WAAW,QAAQ;EAElC,IAAI,QAAQ,WAAW;GACtB,MAAM,YAAY,IAAI,IAAI,MAAM;GAChC,UAAU,SAAS;GACnB,UAAU,KAAK,GAAG,QAAQ,SAAS;EACpC;CACD,OACC,IAAI,MAAM,yBAAyB,OAAO;CAE3C,IAAI,aAAa;AAClB"}
@@ -2,7 +2,7 @@ import { LogMethodNames, StandardLogOptions } from "./types.js";
2
2
  import { MemoryLogReporter } from "./memory.js";
3
3
  import { StandardLog } from "./standard_log.js";
4
4
  //#region ts/standard_log.testing.d.ts
5
- type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogOptions<N> & {
5
+ export type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogOptions<N> & {
6
6
  /**
7
7
  * Send the logs to console for easy debugging.
8
8
  *
@@ -10,10 +10,9 @@ type StandardLogForTestOptions<N extends string = LogMethodNames> = StandardLogO
10
10
  */
11
11
  emitLog?: boolean;
12
12
  };
13
- type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
13
+ export type StandardLogForTest<N extends string = LogMethodNames> = StandardLog<N> & {
14
14
  reporter: MemoryLogReporter;
15
15
  };
16
- declare function createStandardLogForTest<N extends string = LogMethodNames>(options?: StandardLogForTestOptions<N>): StandardLogForTest<N>;
16
+ export declare function createStandardLogForTest<N extends string = LogMethodNames>(options?: StandardLogForTestOptions<N>): StandardLogForTest<N>;
17
17
  //#endregion
18
- export { StandardLogForTest, StandardLogForTestOptions, createStandardLogForTest };
19
18
  //# sourceMappingURL=standard_log.testing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standard_log.testing.d.ts","names":[],"sources":["../ts/standard_log.testing.ts"],"mappings":";;;;KAMY,0BAA0B,mBAAmB,kBAAkB,mBAAmB;;;;;;EAM7F;;KAGW,mBAAmB,mBAAmB,kBAAkB,YAAY;EAC/E,UAAU;;iBAGK,yBAAyB,mBAAmB,gBAC3D,UAAS,0BAA0B,KACjC,mBAAmB"}
1
+ {"version":3,"file":"standard_log.testing.d.ts","names":[],"sources":["../ts/standard_log.testing.ts"],"mappings":";;;;YAMY,0BAA0B,mBAAmB,kBAAkB,mBAAmB;;;;;;EAM7F;;YAGW,mBAAmB,mBAAmB,kBAAkB,YAAY;EAC/E,UAAU;;wBAGK,yBAAyB,mBAAmB,gBAC3D,UAAS,0BAA0B,KACjC,mBAAmB"}
package/esm/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { StackTraceMeta } from "@just-func/types";
2
1
  //#region ts/types.d.ts
3
- type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
2
+ export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
4
3
  /**
5
4
  * A map of custom log levels.
6
5
  *
@@ -19,11 +18,15 @@ type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
19
18
  logLevel?: number;
20
19
  reporters?: LogReporter[];
21
20
  };
22
- interface LoggerOptions extends StackTraceMeta {
21
+ export interface LoggerOptions {
22
+ /**
23
+ * Stack start function: the stack trace is adjusted to start from this function.
24
+ */
25
+ ssf?: (...args: any[]) => any;
23
26
  level?: number;
24
27
  writeTo?: LogReporter | ReporterFilter;
25
28
  }
26
- type Logger<N extends string = LogMethodNames> = {
29
+ export type Logger<N extends string = LogMethodNames> = {
27
30
  readonly id: string;
28
31
  /**
29
32
  * Logger local log level.
@@ -43,17 +46,17 @@ type Logger<N extends string = LogMethodNames> = {
43
46
  /**
44
47
  * Names of the standard log methods.
45
48
  */
46
- type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
47
- type LogEntry = {
49
+ export type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
50
+ export type LogEntry = {
48
51
  id: string;
49
52
  level: number;
50
53
  args: any[];
51
54
  timestamp: Date;
52
55
  };
53
- type LogMethod = (...args: any[]) => void;
54
- type LogFunction = (log: LogMethod, logLevel: number) => string | undefined | void;
55
- type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
56
- interface StandardLogInstance<N extends string = LogMethodNames> {
56
+ export type LogMethod = (...args: any[]) => void;
57
+ export type LogFunction = (log: LogMethod, logLevel: number) => string | undefined | void;
58
+ export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
59
+ export interface StandardLogInstance<N extends string = LogMethodNames> {
57
60
  /**
58
61
  * The current log level.
59
62
  */
@@ -94,16 +97,16 @@ interface StandardLogInstance<N extends string = LogMethodNames> {
94
97
  * Depends on the reporter, it can expect a different return type.
95
98
  * By default the return type is `any[]` which the `console` accepts.
96
99
  */
97
- type LogFormatter<T = any[]> = (entry: LogEntry) => T;
100
+ export type LogFormatter<T = any[]> = (entry: LogEntry) => T;
98
101
  /**
99
102
  * Determines whether the entry should be written.
100
103
  */
101
- type LogFilter = (entry: LogEntry) => boolean;
102
- type LogLevelEntry = {
104
+ export type LogFilter = (entry: LogEntry) => boolean;
105
+ export type LogLevelEntry = {
103
106
  name: string;
104
107
  level: number;
105
108
  };
106
- interface LogReporter<T = any> {
109
+ export interface LogReporter<T = any> {
107
110
  readonly id: string;
108
111
  /**
109
112
  * Specifies the formatter to be used by the reporter.
@@ -121,7 +124,7 @@ interface LogReporter<T = any> {
121
124
  readonly isConsoleReporter?: boolean;
122
125
  write(entry: LogEntry): void;
123
126
  }
124
- type LogReporterOptions<T = any> = {
127
+ export type LogReporterOptions<T = any> = {
125
128
  id?: string;
126
129
  /**
127
130
  * Specifies the formatter to be used by the reporter.
@@ -133,13 +136,12 @@ type LogReporterOptions<T = any> = {
133
136
  */
134
137
  filter?: LogFilter;
135
138
  };
136
- type LogLevel = number;
137
- interface ConsoleLike {
139
+ export type LogLevel = number;
140
+ export interface ConsoleLike {
138
141
  debug(...args: any[]): void;
139
142
  info(...args: any[]): void;
140
143
  warn(...args: any[]): void;
141
144
  error(...args: any[]): void;
142
145
  }
143
146
  //#endregion
144
- export { ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, LogLevel, LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, Logger, LoggerOptions, ReporterFilter, StandardLogInstance, StandardLogOptions };
145
147
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../ts/types.ts"],"mappings":";;KAEY,mBAAmB,kCAAkC;;;;;;;;;;;;;;;EAehE,eAAe,OAAO;EACtB;EACA,YAAY;;UAGI,sBAAsB;EACtC;EACA,UAAU,cAAc;;KAGb,OAAO,mBAAmB;WAC5B;;;;EAIT;;;;;EAKA,SAAS;EACT,GAAG,gBAAgB,GAAG,aAAa;;;;EAInC,MAAM,OAAO;OACP,KAAK,IAAI;;;;KAKJ;KAYA;EACX;EACA;EAEA;EACA,WAAW;;KAGA,gBAAgB;KAEhB,eAAe,KAAK,WAAW;KAE/B,0BAA0B,WAAW;UAEhC,oBAAoB,mBAAmB;;;;EAIvD;;;;EAIA,eAAe;;;;EAIf,WAAW,MAAM;;;;;;;;;;EAUjB,UAAU,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;;;;;;EAY3D,oBAAoB,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;KAQ1D,aAAa,cAAc,OAAO,aAAa;;;;KAK/C,aAAa,OAAO;KAEpB;EAAkB;EAAc;;UAE3B,YAAY;WACnB;;;;;WAKA,WAAW,aAAa;;;;WAIxB,SAAS;;;;;WAKT;EACT,MAAM,OAAO;;KAGF,mBAAmB;EAC9B;;;;;EAKA,YAAY,aAAa;;;;EAIzB,SAAS;;KAGE;UAEK;EAChB,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,SAAS"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../ts/types.ts"],"mappings":";YAAY,mBAAmB,kCAAkC;;;;;;;;;;;;;;;EAehE,eAAe,OAAO;EACtB;EACA,YAAY;;iBAGI;;;;EAIhB,UAAU;EACV;EACA,UAAU,cAAc;;YAGb,OAAO,mBAAmB;WAC5B;;;;EAIT;;;;;EAKA,SAAS;EACT,GAAG,gBAAgB,GAAG,aAAa;;;;EAInC,MAAM,OAAO;OACP,KAAK,IAAI;;;;YAKJ;YAYA;EACX;EACA;EAEA;EACA,WAAW;;YAGA,gBAAgB;YAEhB,eAAe,KAAK,WAAW;YAE/B,0BAA0B,WAAW;iBAEhC,oBAAoB,mBAAmB;;;;EAIvD;;;;EAIA,eAAe;;;;EAIf,WAAW,MAAM;;;;;;;;;;EAUjB,UAAU,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;;;;;;EAY3D,oBAAoB,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;YAQ1D,aAAa,cAAc,OAAO,aAAa;;;;YAK/C,aAAa,OAAO;YAEpB;EAAkB;EAAc;;iBAE3B,YAAY;WACnB;;;;;WAKA,WAAW,aAAa;;;;WAIxB,SAAS;;;;;WAKT;EACT,MAAM,OAAO;;YAGF,mBAAmB;EAC9B;;;;;EAKA,YAAY,aAAa;;;;EAIzB,SAAS;;YAGE;iBAEK;EAChB,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,SAAS"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "standard-log",
3
- "version": "13.3.0",
3
+ "version": "13.3.2",
4
4
  "description": "The standard log library",
5
5
  "homepage": "https://github.com/cyberuni/standard-log/tree/main/packages/log",
6
6
  "bugs": {
@@ -58,24 +58,24 @@
58
58
  "!**/test_utils.*"
59
59
  ],
60
60
  "dependencies": {
61
- "@just-func/types": "^0.6.0",
62
61
  "iso-error": "^7.0.0",
63
62
  "ms": "^2.1.3",
64
- "type-plus": "8.0.0-beta.10"
63
+ "unpartial": "^1.0.8"
65
64
  },
66
65
  "devDependencies": {
67
- "@repobuddy/vitest": "^2.1.1",
66
+ "@repobuddy/vitest": "^3.0.0",
68
67
  "@types/ms": "^2.0.0",
69
68
  "@types/node": "^24.0.0",
70
69
  "@types/ramda": "^0.32.0",
71
- "assertron": "^11.6.0",
70
+ "assertron": "^11.7.2",
72
71
  "depcheck": "^1.4.3",
73
72
  "dirname-filename-esm": "^1.1.1",
74
73
  "ramda": "^0.32.0",
75
74
  "rimraf": "^6.0.0",
76
- "tsdown": "^0.22.14",
75
+ "tsdown": "^0.23.0",
76
+ "type-plus": "8.0.0",
77
77
  "typescript": "^7.0.2",
78
- "vitest": "^4.1.0"
78
+ "vitest": "^5.0.0"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "tsdown",
package/ts/console.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { unpartial } from 'type-plus'
1
+ import { unpartial } from 'unpartial'
2
2
  import { consoleFormatter } from './formatter.js'
3
3
  import { logLevels } from './log_levels.js'
4
4
  import { polyfill } from './platform.js'
package/ts/log_store.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { mapKey, record, reduceByKey, reduceKey } from 'type-plus'
2
1
  import { createConsoleLogReporter } from './console.js'
3
2
  import { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'
3
+ import { record } from './record.js'
4
4
  import type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'
5
5
 
6
6
  export function createLogStore<N extends string = LogMethodNames>(
@@ -32,8 +32,7 @@ export function logLevelStore(options: LogLevelStoreOptions) {
32
32
 
33
33
  const store = {
34
34
  customLevels,
35
- customLevelsReverse: reduceByKey(
36
- customLevels,
35
+ customLevelsReverse: Object.keys(customLevels).reduce(
37
36
  (p, k) => {
38
37
  p[customLevels[k]] = k
39
38
  return p
@@ -49,14 +48,13 @@ export function logLevelStore(options: LogLevelStoreOptions) {
49
48
  return store.customLevels[name] ?? toLogLevel(name)
50
49
  },
51
50
  getAllLevels() {
52
- return reduceKey(
53
- logLevels,
51
+ return (Object.keys(logLevels) as Array<keyof typeof logLevels>).reduce(
54
52
  (result, name) => {
55
53
  if (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })
56
54
 
57
55
  return result
58
56
  },
59
- mapKey(store.customLevels, name => ({ name, level: store.customLevels[name] }))
57
+ Object.keys(store.customLevels).map(name => ({ name, level: store.customLevels[name] }))
60
58
  )
61
59
  }
62
60
  }
package/ts/memory.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { required, unpartial } from 'type-plus'
1
+ import { required, unpartial } from 'unpartial'
2
2
  import { createConsoleLogReporter } from './console.js'
3
3
  import { formatLogLevel } from './formatter.js'
4
4
  import { toInspectLogEntry } from './platform.js'
@@ -1,4 +1,4 @@
1
- import { record } from 'type-plus'
1
+ import { record } from './record.js'
2
2
  import type { ConsoleLike, LogEntry } from './types.js'
3
3
 
4
4
  export const toInspectLogEntry = (e: LogEntry) => e
package/ts/platform.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { inspect } from 'node:util'
2
- import { record } from 'type-plus'
2
+ import { record } from './record.js'
3
3
  import type { ConsoleLike, LogEntry } from './types.js'
4
4
 
5
5
  export const toInspectLogEntry = (e: LogEntry) => (
package/ts/record.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Creates a prototype-less object, optionally seeded with `value`.
3
+ *
4
+ * Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.
5
+ */
6
+ export function record<R extends Record<any, any>>(value?: R): R {
7
+ const r = Object.create(null)
8
+ return value ? Object.assign(r, value) : r
9
+ }
@@ -1,5 +1,5 @@
1
- import { record } from 'type-plus'
2
1
  import type { LogStore } from './log_store.js'
2
+ import { record } from './record.js'
3
3
  import type { LogMethodNames, StandardLogInstance } from './types.js'
4
4
 
5
5
  export const ctx: {
@@ -1,7 +1,8 @@
1
- import { record, required } from 'type-plus'
1
+ import { required } from 'unpartial'
2
2
  import { DEFAULT_LOG_METHOD_NAMES, logLevels } from './log_levels.js'
3
3
  import { createLogStore, type LogStore } from './log_store.js'
4
4
  import { createLogger } from './logger.js'
5
+ import { record } from './record.js'
5
6
  import { ctx } from './standard_log.ctx.js'
6
7
  import type {
7
8
  Logger,
package/ts/types.ts CHANGED
@@ -1,5 +1,3 @@
1
- import type { StackTraceMeta } from '@just-func/types'
2
-
3
1
  export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
4
2
  /**
5
3
  * A map of custom log levels.
@@ -20,7 +18,11 @@ export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames>
20
18
  reporters?: LogReporter[]
21
19
  }
22
20
 
23
- export interface LoggerOptions extends StackTraceMeta {
21
+ export interface LoggerOptions {
22
+ /**
23
+ * Stack start function: the stack trace is adjusted to start from this function.
24
+ */
25
+ ssf?: (...args: any[]) => any
24
26
  level?: number
25
27
  writeTo?: LogReporter | ReporterFilter
26
28
  }