standard-log 13.2.0 → 13.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) 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 +1 -1
  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 +3 -2
  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.d.ts +2 -3
  24. package/cjs/platform.d.ts.map +1 -1
  25. package/cjs/platform.js +1 -1
  26. package/cjs/standard_log.ctx.d.ts +1 -2
  27. package/cjs/standard_log.ctx.d.ts.map +1 -1
  28. package/cjs/standard_log.d.ts +7 -8
  29. package/cjs/standard_log.d.ts.map +1 -1
  30. package/cjs/standard_log.testing.d.ts +3 -4
  31. package/cjs/standard_log.testing.d.ts.map +1 -1
  32. package/cjs/types.d.ts +16 -17
  33. package/cjs/types.d.ts.map +1 -1
  34. package/dist/standard-log.esm.js +110 -51
  35. package/dist/standard-log.esm.js.map +1 -1
  36. package/dist/standard-log.iife.js +110 -51
  37. package/dist/standard-log.iife.js.map +1 -1
  38. package/esm/console.d.ts +5 -6
  39. package/esm/console.d.ts.map +1 -1
  40. package/esm/console.js +1 -1
  41. package/esm/console.js.map +1 -1
  42. package/esm/errors.d.ts +2 -3
  43. package/esm/errors.d.ts.map +1 -1
  44. package/esm/formatter.d.ts +5 -6
  45. package/esm/formatter.d.ts.map +1 -1
  46. package/esm/log_levels.d.ts +4 -5
  47. package/esm/log_levels.d.ts.map +1 -1
  48. package/esm/log_store.d.ts +4 -5
  49. package/esm/log_store.d.ts.map +1 -1
  50. package/esm/log_store.js +2 -2
  51. package/esm/log_store.js.map +1 -1
  52. package/esm/logger.d.ts +1 -2
  53. package/esm/logger.d.ts.map +1 -1
  54. package/esm/memory.d.ts +5 -6
  55. package/esm/memory.d.ts.map +1 -1
  56. package/esm/memory.js +2 -1
  57. package/esm/memory.js.map +1 -1
  58. package/esm/platform.browser.d.ts +2 -3
  59. package/esm/platform.browser.d.ts.map +1 -1
  60. package/esm/platform.d.ts +2 -3
  61. package/esm/platform.d.ts.map +1 -1
  62. package/esm/platform.js +1 -1
  63. package/esm/standard_log.ctx.d.ts +1 -2
  64. package/esm/standard_log.ctx.d.ts.map +1 -1
  65. package/esm/standard_log.d.ts +7 -8
  66. package/esm/standard_log.d.ts.map +1 -1
  67. package/esm/standard_log.testing.d.ts +3 -4
  68. package/esm/standard_log.testing.d.ts.map +1 -1
  69. package/esm/types.d.ts +16 -17
  70. package/esm/types.d.ts.map +1 -1
  71. package/package.json +7 -6
  72. package/ts/console.ts +1 -1
  73. package/ts/log_store.ts +2 -2
  74. package/ts/memory.ts +2 -1
@@ -1,5 +1,5 @@
1
1
  //#region ts/log_levels.d.ts
2
- declare const logLevels: {
2
+ export declare const logLevels: {
3
3
  /**
4
4
  * none: 0
5
5
  */
@@ -73,12 +73,11 @@ declare const logLevels: {
73
73
  /**
74
74
  * Convert default log level value to log level name.
75
75
  */
76
- declare function toLogLevelName(level: number): "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "planck" | "trace" | "warn";
76
+ export declare function toLogLevelName(level: number): "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "planck" | "trace" | "warn";
77
77
  /**
78
78
  * Convert default log level name to log level value.
79
79
  */
80
- declare function toLogLevel(name: string): number | undefined;
81
- declare const DEFAULT_LOG_METHOD_NAMES: string[];
80
+ export declare function toLogLevel(name: string): number | undefined;
81
+ export declare const DEFAULT_LOG_METHOD_NAMES: string[];
82
82
  //#endregion
83
- export { DEFAULT_LOG_METHOD_NAMES, logLevels, toLogLevel, toLogLevelName };
84
83
  //# sourceMappingURL=log_levels.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"log_levels.d.ts","names":[],"sources":["../ts/log_levels.ts"],"mappings":";cAAa;;;;EAIZ;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;;EAOA;;;;EAIA;;;;;iBAMe,eAAe;;;;iBAgBf,WAAW;cAId"}
1
+ {"version":3,"file":"log_levels.d.ts","names":[],"sources":["../ts/log_levels.ts"],"mappings":";qBAAa;;;;EAIZ;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;;EAOA;;;;EAIA;;;;;wBAMe,eAAe;;;;wBAgBf,WAAW;qBAId"}
@@ -1,17 +1,17 @@
1
1
  import { LogLevel, LogMethodNames, LogReporter, Logger, StandardLogOptions } from "./types.js";
2
2
  //#region ts/log_store.d.ts
3
- declare function createLogStore<N extends string = LogMethodNames>(options: Required<StandardLogOptions<N>>): LogStore;
4
- interface LogStore {
3
+ export declare function createLogStore<N extends string = LogMethodNames>(options: Required<StandardLogOptions<N>>): LogStore;
4
+ export interface LogStore {
5
5
  loggers: Record<string, Logger>;
6
6
  nonConsoleLoggers: Record<string, Logger>;
7
7
  reporters: LogReporter[];
8
8
  logLevel: LogLevel;
9
9
  logLevelStore: ReturnType<typeof logLevelStore>;
10
10
  }
11
- interface LogLevelStoreOptions {
11
+ export interface LogLevelStoreOptions {
12
12
  customLevels?: Record<string, number>;
13
13
  }
14
- declare function logLevelStore(options: LogLevelStoreOptions): {
14
+ export declare function logLevelStore(options: LogLevelStoreOptions): {
15
15
  getName(level: number): string;
16
16
  getLevel(name: string): number;
17
17
  getAllLevels(): {
@@ -20,5 +20,4 @@ declare function logLevelStore(options: LogLevelStoreOptions): {
20
20
  }[];
21
21
  };
22
22
  //#endregion
23
- export { LogLevelStoreOptions, LogStore, createLogStore, logLevelStore };
24
23
  //# sourceMappingURL=log_store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"log_store.d.ts","names":[],"sources":["../ts/log_store.ts"],"mappings":";;iBAKgB,eAAe,mBAAmB,gBACjD,SAAS,SAAS,mBAAmB,MACnC;UAUc;EAChB,SAAS,eAAe;EACxB,mBAAmB,eAAe;EAClC,WAAW;EACX,UAAU;EACV,eAAe,kBAAkB;;UAGjB;EAChB,eAAe;;iBAGA,cAAc,SAAS;EAerC,QAAO;EAGP,SAAQ;EAGR"}
1
+ {"version":3,"file":"log_store.d.ts","names":[],"sources":["../ts/log_store.ts"],"mappings":";;wBAKgB,eAAe,mBAAmB,gBACjD,SAAS,SAAS,mBAAmB,MACnC;iBAUc;EAChB,SAAS,eAAe;EACxB,mBAAmB,eAAe;EAClC,WAAW;EACX,UAAU;EACV,eAAe,kBAAkB;;iBAGjB;EAChB,eAAe;;wBAGA,cAAc,SAAS;EAerC,QAAO;EAGP,SAAQ;EAGR"}
package/esm/log_store.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { logLevels, toLogLevel, toLogLevelName } from "./log_levels.js";
2
2
  import { createConsoleLogReporter } from "./console.js";
3
- import { mapKey, record, reduceByKey, reduceKey } from "type-plus";
3
+ import { mapKey, record, reduceByKey } from "type-plus";
4
4
  //#region ts/log_store.ts
5
5
  function createLogStore(options) {
6
6
  return {
@@ -28,7 +28,7 @@ function logLevelStore(options) {
28
28
  return store.customLevels[name] ?? toLogLevel(name);
29
29
  },
30
30
  getAllLevels() {
31
- return reduceKey(logLevels, (result, name) => {
31
+ return reduceByKey(logLevels, (result, name) => {
32
32
  if (name !== "none" && name !== "all") result.push({
33
33
  name,
34
34
  level: logLevels[name]
@@ -1 +1 @@
1
- {"version":3,"file":"log_store.js","names":[],"sources":["../ts/log_store.ts"],"sourcesContent":["import { mapKey, record, reduceByKey, reduceKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'\nimport type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore<N extends string = LogMethodNames>(\n\toptions: Required<StandardLogOptions<N>>\n): LogStore {\n\treturn {\n\t\tloggers: record(),\n\t\tnonConsoleLoggers: record(),\n\t\treporters: options.reporters || [createConsoleLogReporter()],\n\t\tlogLevel: options.logLevel,\n\t\tlogLevelStore: logLevelStore(options)\n\t}\n}\n\nexport interface LogStore {\n\tloggers: Record<string, Logger>\n\tnonConsoleLoggers: Record<string, Logger>\n\treporters: LogReporter[]\n\tlogLevel: LogLevel\n\tlogLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n\tcustomLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n\tconst customLevels = options.customLevels || record()\n\n\tconst store = {\n\t\tcustomLevels,\n\t\tcustomLevelsReverse: reduceByKey(\n\t\t\tcustomLevels,\n\t\t\t(p, k) => {\n\t\t\t\tp[customLevels[k]] = k\n\t\t\t\treturn p\n\t\t\t},\n\t\t\t{} as Record<number, string>\n\t\t)\n\t}\n\treturn {\n\t\tgetName(level: number) {\n\t\t\treturn store.customLevelsReverse[level] ?? toLogLevelName(level)\n\t\t},\n\t\tgetLevel(name: string) {\n\t\t\treturn store.customLevels[name] ?? toLogLevel(name)\n\t\t},\n\t\tgetAllLevels() {\n\t\t\treturn reduceKey(\n\t\t\t\tlogLevels,\n\t\t\t\t(result, name) => {\n\t\t\t\t\tif (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t\tmapKey(store.customLevels, name => ({ name, level: store.customLevels[name] }))\n\t\t\t)\n\t\t}\n\t}\n}\n"],"mappings":";;;;AAKA,SAAgB,eACf,SACW;CACX,OAAO;EACN,SAAS,OAAO;EAChB,mBAAmB,OAAO;EAC1B,WAAW,QAAQ,aAAa,CAAC,yBAAyB,CAAC;EAC3D,UAAU,QAAQ;EAClB,eAAe,cAAc,OAAO;CACrC;AACD;AAcA,SAAgB,cAAc,SAA+B;CAC5D,MAAM,eAAe,QAAQ,gBAAgB,OAAO;CAEpD,MAAM,QAAQ;EACb;EACA,qBAAqB,YACpB,eACC,GAAG,MAAM;GACT,EAAE,aAAa,MAAM;GACrB,OAAO;EACR,GACA,CAAC,CACF;CACD;CACA,OAAO;EACN,QAAQ,OAAe;GACtB,OAAO,MAAM,oBAAoB,UAAU,eAAe,KAAK;EAChE;EACA,SAAS,MAAc;GACtB,OAAO,MAAM,aAAa,SAAS,WAAW,IAAI;EACnD;EACA,eAAe;GACd,OAAO,UACN,YACC,QAAQ,SAAS;IACjB,IAAI,SAAS,UAAU,SAAS,OAAO,OAAO,KAAK;KAAE;KAAM,OAAO,UAAU;IAAM,CAAC;IAEnF,OAAO;GACR,GACA,OAAO,MAAM,eAAc,UAAS;IAAE;IAAM,OAAO,MAAM,aAAa;GAAM,EAAE,CAC/E;EACD;CACD;AACD"}
1
+ {"version":3,"file":"log_store.js","names":[],"sources":["../ts/log_store.ts"],"sourcesContent":["import { mapKey, record, reduceByKey } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'\nimport type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore<N extends string = LogMethodNames>(\n\toptions: Required<StandardLogOptions<N>>\n): LogStore {\n\treturn {\n\t\tloggers: record(),\n\t\tnonConsoleLoggers: record(),\n\t\treporters: options.reporters || [createConsoleLogReporter()],\n\t\tlogLevel: options.logLevel,\n\t\tlogLevelStore: logLevelStore(options)\n\t}\n}\n\nexport interface LogStore {\n\tloggers: Record<string, Logger>\n\tnonConsoleLoggers: Record<string, Logger>\n\treporters: LogReporter[]\n\tlogLevel: LogLevel\n\tlogLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n\tcustomLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n\tconst customLevels = options.customLevels || record()\n\n\tconst store = {\n\t\tcustomLevels,\n\t\tcustomLevelsReverse: reduceByKey(\n\t\t\tcustomLevels,\n\t\t\t(p, k) => {\n\t\t\t\tp[customLevels[k]] = k\n\t\t\t\treturn p\n\t\t\t},\n\t\t\t{} as Record<number, string>\n\t\t)\n\t}\n\treturn {\n\t\tgetName(level: number) {\n\t\t\treturn store.customLevelsReverse[level] ?? toLogLevelName(level)\n\t\t},\n\t\tgetLevel(name: string) {\n\t\t\treturn store.customLevels[name] ?? toLogLevel(name)\n\t\t},\n\t\tgetAllLevels() {\n\t\t\treturn reduceByKey(\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"],"mappings":";;;;AAKA,SAAgB,eACf,SACW;CACX,OAAO;EACN,SAAS,OAAO;EAChB,mBAAmB,OAAO;EAC1B,WAAW,QAAQ,aAAa,CAAC,yBAAyB,CAAC;EAC3D,UAAU,QAAQ;EAClB,eAAe,cAAc,OAAO;CACrC;AACD;AAcA,SAAgB,cAAc,SAA+B;CAC5D,MAAM,eAAe,QAAQ,gBAAgB,OAAO;CAEpD,MAAM,QAAQ;EACb;EACA,qBAAqB,YACpB,eACC,GAAG,MAAM;GACT,EAAE,aAAa,MAAM;GACrB,OAAO;EACR,GACA,CAAC,CACF;CACD;CACA,OAAO;EACN,QAAQ,OAAe;GACtB,OAAO,MAAM,oBAAoB,UAAU,eAAe,KAAK;EAChE;EACA,SAAS,MAAc;GACtB,OAAO,MAAM,aAAa,SAAS,WAAW,IAAI;EACnD;EACA,eAAe;GACd,OAAO,YACN,YACC,QAAQ,SAAS;IACjB,IAAI,SAAS,UAAU,SAAS,OAAO,OAAO,KAAK;KAAE;KAAM,OAAO,UAAU;IAAM,CAAC;IAEnF,OAAO;GACR,GACA,OAAO,MAAM,eAAc,UAAS;IAAE;IAAM,OAAO,MAAM,aAAa;GAAM,EAAE,CAC/E;EACD;CACD;AACD"}
package/esm/logger.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { LogMethodNames, Logger, LoggerOptions } from "./types.js";
2
2
  import { LogStore } from "./log_store.js";
3
3
  //#region ts/logger.d.ts
4
- declare function createLogger<N extends string = LogMethodNames>(store: LogStore, id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
4
+ export declare function createLogger<N extends string = LogMethodNames>(store: LogStore, id: string, options?: LoggerOptions): Logger<N | LogMethodNames>;
5
5
  //#endregion
6
- export { createLogger };
7
6
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","names":[],"sources":["../ts/logger.ts"],"mappings":";;;iBAYgB,aAAa,mBAAmB,gBAC/C,OAAO,UACP,YACA,UAAU,gBACR,OAAO,IAAI"}
1
+ {"version":3,"file":"logger.d.ts","names":[],"sources":["../ts/logger.ts"],"mappings":";;;wBAYgB,aAAa,mBAAmB,gBAC/C,OAAO,UACP,YACA,UAAU,gBACR,OAAO,IAAI"}
package/esm/memory.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from "./types.js";
2
2
  //#region ts/memory.d.ts
3
- type MemoryLogReporter = LogReporter<LogEntry> & {
3
+ export type MemoryLogReporter = LogReporter<LogEntry> & {
4
4
  logs: LogEntry[];
5
5
  /**
6
6
  * Gets a simple log message for testing.
@@ -13,10 +13,9 @@ type MemoryLogReporter = LogReporter<LogEntry> & {
13
13
  getLogMessagesWithIdAndLevel(): string[];
14
14
  emit(): void;
15
15
  };
16
- type MemoryLogFormatter = LogFormatter<LogEntry>;
17
- declare function toMessageWithLevel(logs: LogEntry[]): string;
18
- declare function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
19
- declare function createMemoryWithConsoleLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
16
+ export type MemoryLogFormatter = LogFormatter<LogEntry>;
17
+ export declare function toMessageWithLevel(logs: LogEntry[]): string;
18
+ export declare function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
19
+ export declare function createMemoryWithConsoleLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter;
20
20
  //#endregion
21
- export { MemoryLogFormatter, MemoryLogReporter, createMemoryLogReporter, createMemoryWithConsoleLogReporter, toMessageWithLevel };
22
21
  //# sourceMappingURL=memory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","names":[],"sources":["../ts/memory.ts"],"mappings":";;KAMY,oBAAoB,YAAY;EAC3C,MAAM;;;;;EAKN;EACA;EACA;EACA;EACA;EACA;;KAGW,qBAAqB,aAAa;iBAE9B,mBAAmB,MAAM;iBAazB,wBAAwB,UAAU,mBAAmB,YAAY;iBA+CjE,mCACf,UAAU,mBAAmB,YAC3B"}
1
+ {"version":3,"file":"memory.d.ts","names":[],"sources":["../ts/memory.ts"],"mappings":";;YAOY,oBAAoB,YAAY;EAC3C,MAAM;;;;;EAKN;EACA;EACA;EACA;EACA;EACA;;YAGW,qBAAqB,aAAa;wBAE9B,mBAAmB,MAAM;wBAazB,wBAAwB,UAAU,mBAAmB,YAAY;wBA+CjE,mCACf,UAAU,mBAAmB,YAC3B"}
package/esm/memory.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { formatLogLevel } from "./formatter.js";
2
2
  import { toInspectLogEntry } from "./platform.js";
3
3
  import { createConsoleLogReporter } from "./console.js";
4
- import { required, unpartial } from "type-plus";
4
+ import { unpartial } from "unpartial";
5
+ import { required } from "type-plus";
5
6
  //#region ts/memory.ts
6
7
  function toMessageWithLevel(logs) {
7
8
  return logs.map(toInspectLogEntry).map((log) => `${formatLogLevel(log.level)} ${log.args.join(" ")}`).join("\n").replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, "");
package/esm/memory.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"memory.js","names":[],"sources":["../ts/memory.ts"],"sourcesContent":["import { required, unpartial } from 'type-plus'\nimport { createConsoleLogReporter } from './console.js'\nimport { formatLogLevel } from './formatter.js'\nimport { toInspectLogEntry } from './platform.js'\nimport type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport type MemoryLogReporter = LogReporter<LogEntry> & {\n\tlogs: LogEntry[]\n\t/**\n\t * Gets a simple log message for testing.\n\t * The message only contains arguments for each log entry.\n\t */\n\tgetLogMessage(): string\n\tgetLogMessages(): string[]\n\tgetLogMessageWithLevel(): string\n\tgetLogMessagesWithLevel(): string[]\n\tgetLogMessagesWithIdAndLevel(): string[]\n\temit(): void\n}\n\nexport type MemoryLogFormatter = LogFormatter<LogEntry>\n\nexport function toMessageWithLevel(logs: LogEntry[]) {\n\treturn (\n\t\tlogs\n\t\t\t.map(toInspectLogEntry)\n\t\t\t.map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t\t.join('\\n')\n\t\t\t// if it has more than this log,\n\t\t\t// we assume it is running under tests,\n\t\t\t// and remove this log to simplify testing.\n\t\t\t.replace(/^\\(WARN\\) already configured for test, ignoring config\\(\\) call\\n/, '')\n\t)\n}\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n\treturn Object.freeze(buildMemoryReporter(unpartial({ id: 'memory' }, options)))\n}\n\nfunction buildMemoryReporter(options?: LogReporterOptions<LogEntry>) {\n\tconst { id, formatter, filter } = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n\tconst logs: LogEntry[] = []\n\treturn {\n\t\tid,\n\t\tget formatter() {\n\t\t\treturn formatter\n\t\t},\n\t\tget filter() {\n\t\t\treturn filter\n\t\t},\n\t\tlogs,\n\t\twrite(entry: LogEntry) {\n\t\t\tif (filter && !filter(entry)) return\n\t\t\tlogs.push(formatter(entry))\n\t\t},\n\t\tgetLogMessage() {\n\t\t\treturn this.getLogMessages().join('\\n')\n\t\t},\n\t\tgetLogMessages() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => log.args.join(' '))\n\t\t},\n\t\tgetLogMessagesWithLevel() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessagesWithIdAndLevel() {\n\t\t\treturn logs\n\t\t\t\t.map(toInspectLogEntry)\n\t\t\t\t.map(log => `${log.id} ${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessageWithLevel() {\n\t\t\treturn toMessageWithLevel(logs)\n\t\t},\n\t\t/**\n\t\t * emit the saved log to console for easy debugging\n\t\t */\n\t\temit() {\n\t\t\tconst reporter = createConsoleLogReporter()\n\t\t\tlogs.forEach(l => reporter.write(l))\n\t\t}\n\t}\n}\n\nexport function createMemoryWithConsoleLogReporter(\n\toptions?: LogReporterOptions<LogEntry>\n): MemoryLogReporter {\n\treturn Object.freeze(\n\t\tObject.assign(buildMemoryReporter(unpartial({ id: 'memory-with-console' }, options)), {\n\t\t\tisConsoleReporter: true\n\t\t})\n\t)\n}\n"],"mappings":";;;;;AAsBA,SAAgB,mBAAmB,MAAkB;CACpD,OACC,KACE,IAAI,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAG,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG,CAAC,CAChE,KAAK,IAAI,CAAC,CAIV,QAAQ,qEAAqE,EAAE;AAEnF;AAEA,SAAgB,wBAAwB,SAA2D;CAClG,OAAO,OAAO,OAAO,oBAAoB,UAAU,EAAE,IAAI,SAAS,GAAG,OAAO,CAAC,CAAC;AAC/E;AAEA,SAAS,oBAAoB,SAAwC;CACpE,MAAM,EAAE,IAAI,WAAW,WAAW,SAAS;EAAE,IAAI;EAAU,YAAY,MAAgB;CAAE,GAAG,OAAO;CACnG,MAAM,OAAmB,CAAC;CAC1B,OAAO;EACN;EACA,IAAI,YAAY;GACf,OAAO;EACR;EACA,IAAI,SAAS;GACZ,OAAO;EACR;EACA;EACA,MAAM,OAAiB;GACtB,IAAI,UAAU,CAAC,OAAO,KAAK,GAAG;GAC9B,KAAK,KAAK,UAAU,KAAK,CAAC;EAC3B;EACA,gBAAgB;GACf,OAAO,KAAK,eAAe,CAAC,CAAC,KAAK,IAAI;EACvC;EACA,iBAAiB;GAChB,OAAO,KAAK,IAAI,iBAAiB,CAAC,CAAC,KAAI,QAAO,IAAI,KAAK,KAAK,GAAG,CAAC;EACjE;EACA,0BAA0B;GACzB,OAAO,KAAK,IAAI,iBAAiB,CAAC,CAAC,KAAI,QAAO,GAAG,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EACnG;EACA,+BAA+B;GAC9B,OAAO,KACL,IAAI,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAG,IAAI,GAAG,GAAG,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EAC5E;EACA,yBAAyB;GACxB,OAAO,mBAAmB,IAAI;EAC/B;;;;EAIA,OAAO;GACN,MAAM,WAAW,yBAAyB;GAC1C,KAAK,SAAQ,MAAK,SAAS,MAAM,CAAC,CAAC;EACpC;CACD;AACD;AAEA,SAAgB,mCACf,SACoB;CACpB,OAAO,OAAO,OACb,OAAO,OAAO,oBAAoB,UAAU,EAAE,IAAI,sBAAsB,GAAG,OAAO,CAAC,GAAG,EACrF,mBAAmB,KACpB,CAAC,CACF;AACD"}
1
+ {"version":3,"file":"memory.js","names":[],"sources":["../ts/memory.ts"],"sourcesContent":["import { required } from 'type-plus'\nimport { unpartial } from 'unpartial'\nimport { createConsoleLogReporter } from './console.js'\nimport { formatLogLevel } from './formatter.js'\nimport { toInspectLogEntry } from './platform.js'\nimport type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport type MemoryLogReporter = LogReporter<LogEntry> & {\n\tlogs: LogEntry[]\n\t/**\n\t * Gets a simple log message for testing.\n\t * The message only contains arguments for each log entry.\n\t */\n\tgetLogMessage(): string\n\tgetLogMessages(): string[]\n\tgetLogMessageWithLevel(): string\n\tgetLogMessagesWithLevel(): string[]\n\tgetLogMessagesWithIdAndLevel(): string[]\n\temit(): void\n}\n\nexport type MemoryLogFormatter = LogFormatter<LogEntry>\n\nexport function toMessageWithLevel(logs: LogEntry[]) {\n\treturn (\n\t\tlogs\n\t\t\t.map(toInspectLogEntry)\n\t\t\t.map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t\t.join('\\n')\n\t\t\t// if it has more than this log,\n\t\t\t// we assume it is running under tests,\n\t\t\t// and remove this log to simplify testing.\n\t\t\t.replace(/^\\(WARN\\) already configured for test, ignoring config\\(\\) call\\n/, '')\n\t)\n}\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n\treturn Object.freeze(buildMemoryReporter(unpartial({ id: 'memory' }, options)))\n}\n\nfunction buildMemoryReporter(options?: LogReporterOptions<LogEntry>) {\n\tconst { id, formatter, filter } = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n\tconst logs: LogEntry[] = []\n\treturn {\n\t\tid,\n\t\tget formatter() {\n\t\t\treturn formatter\n\t\t},\n\t\tget filter() {\n\t\t\treturn filter\n\t\t},\n\t\tlogs,\n\t\twrite(entry: LogEntry) {\n\t\t\tif (filter && !filter(entry)) return\n\t\t\tlogs.push(formatter(entry))\n\t\t},\n\t\tgetLogMessage() {\n\t\t\treturn this.getLogMessages().join('\\n')\n\t\t},\n\t\tgetLogMessages() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => log.args.join(' '))\n\t\t},\n\t\tgetLogMessagesWithLevel() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessagesWithIdAndLevel() {\n\t\t\treturn logs\n\t\t\t\t.map(toInspectLogEntry)\n\t\t\t\t.map(log => `${log.id} ${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessageWithLevel() {\n\t\t\treturn toMessageWithLevel(logs)\n\t\t},\n\t\t/**\n\t\t * emit the saved log to console for easy debugging\n\t\t */\n\t\temit() {\n\t\t\tconst reporter = createConsoleLogReporter()\n\t\t\tlogs.forEach(l => reporter.write(l))\n\t\t}\n\t}\n}\n\nexport function createMemoryWithConsoleLogReporter(\n\toptions?: LogReporterOptions<LogEntry>\n): MemoryLogReporter {\n\treturn Object.freeze(\n\t\tObject.assign(buildMemoryReporter(unpartial({ id: 'memory-with-console' }, options)), {\n\t\t\tisConsoleReporter: true\n\t\t})\n\t)\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,mBAAmB,MAAkB;CACpD,OACC,KACE,IAAI,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAG,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG,CAAC,CAChE,KAAK,IAAI,CAAC,CAIV,QAAQ,qEAAqE,EAAE;AAEnF;AAEA,SAAgB,wBAAwB,SAA2D;CAClG,OAAO,OAAO,OAAO,oBAAoB,UAAU,EAAE,IAAI,SAAS,GAAG,OAAO,CAAC,CAAC;AAC/E;AAEA,SAAS,oBAAoB,SAAwC;CACpE,MAAM,EAAE,IAAI,WAAW,WAAW,SAAS;EAAE,IAAI;EAAU,YAAY,MAAgB;CAAE,GAAG,OAAO;CACnG,MAAM,OAAmB,CAAC;CAC1B,OAAO;EACN;EACA,IAAI,YAAY;GACf,OAAO;EACR;EACA,IAAI,SAAS;GACZ,OAAO;EACR;EACA;EACA,MAAM,OAAiB;GACtB,IAAI,UAAU,CAAC,OAAO,KAAK,GAAG;GAC9B,KAAK,KAAK,UAAU,KAAK,CAAC;EAC3B;EACA,gBAAgB;GACf,OAAO,KAAK,eAAe,CAAC,CAAC,KAAK,IAAI;EACvC;EACA,iBAAiB;GAChB,OAAO,KAAK,IAAI,iBAAiB,CAAC,CAAC,KAAI,QAAO,IAAI,KAAK,KAAK,GAAG,CAAC;EACjE;EACA,0BAA0B;GACzB,OAAO,KAAK,IAAI,iBAAiB,CAAC,CAAC,KAAI,QAAO,GAAG,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EACnG;EACA,+BAA+B;GAC9B,OAAO,KACL,IAAI,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAG,IAAI,GAAG,GAAG,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EAC5E;EACA,yBAAyB;GACxB,OAAO,mBAAmB,IAAI;EAC/B;;;;EAIA,OAAO;GACN,MAAM,WAAW,yBAAyB;GAC1C,KAAK,SAAQ,MAAK,SAAS,MAAM,CAAC,CAAC;EACpC;CACD;AACD;AAEA,SAAgB,mCACf,SACoB;CACpB,OAAO,OAAO,OACb,OAAO,OAAO,oBAAoB,UAAU,EAAE,IAAI,sBAAsB,GAAG,OAAO,CAAC,GAAG,EACrF,mBAAmB,KACpB,CAAC,CACF;AACD"}
@@ -1,9 +1,8 @@
1
1
  import { ConsoleLike, LogEntry } from "./types.js";
2
2
  //#region ts/platform.browser.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.browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.browser.d.ts","names":[],"sources":["../ts/platform.browser.ts"],"mappings":";;cAGa,oBAAiB,GAAO,aAAQ;cAEhC;EAAY,UAAU"}
1
+ {"version":3,"file":"platform.browser.d.ts","names":[],"sources":["../ts/platform.browser.ts"],"mappings":";;qBAGa,oBAAiB,GAAO,aAAQ;qBAEhC;EAAY,UAAU"}
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,5 +1,5 @@
1
- import { record } from "type-plus";
2
1
  import { inspect } from "node:util";
2
+ import { record } from "type-plus";
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);
5
5
  const polyfill = record();
@@ -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,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":";;;iBAaiB,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"}
@@ -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,6 @@
1
1
  import { StackTraceMeta } from "@just-func/types";
2
2
  //#region ts/types.d.ts
3
- type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
3
+ export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
4
4
  /**
5
5
  * A map of custom log levels.
6
6
  *
@@ -19,11 +19,11 @@ type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
19
19
  logLevel?: number;
20
20
  reporters?: LogReporter[];
21
21
  };
22
- interface LoggerOptions extends StackTraceMeta {
22
+ export interface LoggerOptions extends StackTraceMeta {
23
23
  level?: number;
24
24
  writeTo?: LogReporter | ReporterFilter;
25
25
  }
26
- type Logger<N extends string = LogMethodNames> = {
26
+ export type Logger<N extends string = LogMethodNames> = {
27
27
  readonly id: string;
28
28
  /**
29
29
  * Logger local log level.
@@ -43,17 +43,17 @@ type Logger<N extends string = LogMethodNames> = {
43
43
  /**
44
44
  * Names of the standard log methods.
45
45
  */
46
- type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
47
- type LogEntry = {
46
+ export type LogMethodNames = 'emergency' | 'alert' | 'critical' | 'error' | 'warn' | 'notice' | 'info' | 'debug' | 'trace' | 'planck';
47
+ export type LogEntry = {
48
48
  id: string;
49
49
  level: number;
50
50
  args: any[];
51
51
  timestamp: Date;
52
52
  };
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> {
53
+ export type LogMethod = (...args: any[]) => void;
54
+ export type LogFunction = (log: LogMethod, logLevel: number) => string | undefined | void;
55
+ export type ReporterFilter = string | RegExp | ((reporterId: string) => boolean);
56
+ export interface StandardLogInstance<N extends string = LogMethodNames> {
57
57
  /**
58
58
  * The current log level.
59
59
  */
@@ -94,16 +94,16 @@ interface StandardLogInstance<N extends string = LogMethodNames> {
94
94
  * Depends on the reporter, it can expect a different return type.
95
95
  * By default the return type is `any[]` which the `console` accepts.
96
96
  */
97
- type LogFormatter<T = any[]> = (entry: LogEntry) => T;
97
+ export type LogFormatter<T = any[]> = (entry: LogEntry) => T;
98
98
  /**
99
99
  * Determines whether the entry should be written.
100
100
  */
101
- type LogFilter = (entry: LogEntry) => boolean;
102
- type LogLevelEntry = {
101
+ export type LogFilter = (entry: LogEntry) => boolean;
102
+ export type LogLevelEntry = {
103
103
  name: string;
104
104
  level: number;
105
105
  };
106
- interface LogReporter<T = any> {
106
+ export interface LogReporter<T = any> {
107
107
  readonly id: string;
108
108
  /**
109
109
  * Specifies the formatter to be used by the reporter.
@@ -121,7 +121,7 @@ interface LogReporter<T = any> {
121
121
  readonly isConsoleReporter?: boolean;
122
122
  write(entry: LogEntry): void;
123
123
  }
124
- type LogReporterOptions<T = any> = {
124
+ export type LogReporterOptions<T = any> = {
125
125
  id?: string;
126
126
  /**
127
127
  * Specifies the formatter to be used by the reporter.
@@ -133,13 +133,12 @@ type LogReporterOptions<T = any> = {
133
133
  */
134
134
  filter?: LogFilter;
135
135
  };
136
- type LogLevel = number;
137
- interface ConsoleLike {
136
+ export type LogLevel = number;
137
+ export interface ConsoleLike {
138
138
  debug(...args: any[]): void;
139
139
  info(...args: any[]): void;
140
140
  warn(...args: any[]): void;
141
141
  error(...args: any[]): void;
142
142
  }
143
143
  //#endregion
144
- export { ConsoleLike, LogEntry, LogFilter, LogFormatter, LogFunction, LogLevel, LogLevelEntry, LogMethod, LogMethodNames, LogReporter, LogReporterOptions, Logger, LoggerOptions, ReporterFilter, StandardLogInstance, StandardLogOptions };
145
144
  //# 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":";;YAEY,mBAAmB,kCAAkC;;;;;;;;;;;;;;;EAehE,eAAe,OAAO;EACtB;EACA,YAAY;;iBAGI,sBAAsB;EACtC;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.2.0",
3
+ "version": "13.3.1",
4
4
  "description": "The standard log library",
5
5
  "homepage": "https://github.com/cyberuni/standard-log/tree/main/packages/log",
6
6
  "bugs": {
@@ -58,13 +58,14 @@
58
58
  "!**/test_utils.*"
59
59
  ],
60
60
  "dependencies": {
61
- "@just-func/types": "^0.6.0",
62
- "iso-error": "^6.0.5",
61
+ "@just-func/types": "^0.6.1",
62
+ "iso-error": "^7.0.0",
63
63
  "ms": "^2.1.3",
64
- "type-plus": "8.0.0-beta.10"
64
+ "type-plus": "8.0.0-beta.12",
65
+ "unpartial": "^1.0.8"
65
66
  },
66
67
  "devDependencies": {
67
- "@repobuddy/vitest": "^2.1.1",
68
+ "@repobuddy/vitest": "^2.3.0",
68
69
  "@types/ms": "^2.0.0",
69
70
  "@types/node": "^24.0.0",
70
71
  "@types/ramda": "^0.32.0",
@@ -73,7 +74,7 @@
73
74
  "dirname-filename-esm": "^1.1.1",
74
75
  "ramda": "^0.32.0",
75
76
  "rimraf": "^6.0.0",
76
- "tsdown": "^0.22.14",
77
+ "tsdown": "^0.23.0",
77
78
  "typescript": "^7.0.2",
78
79
  "vitest": "^4.1.0"
79
80
  },
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,4 +1,4 @@
1
- import { mapKey, record, reduceByKey, reduceKey } from 'type-plus'
1
+ import { mapKey, record, reduceByKey } from 'type-plus'
2
2
  import { createConsoleLogReporter } from './console.js'
3
3
  import { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'
4
4
  import type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'
@@ -49,7 +49,7 @@ export function logLevelStore(options: LogLevelStoreOptions) {
49
49
  return store.customLevels[name] ?? toLogLevel(name)
50
50
  },
51
51
  getAllLevels() {
52
- return reduceKey(
52
+ return reduceByKey(
53
53
  logLevels,
54
54
  (result, name) => {
55
55
  if (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })
package/ts/memory.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { required, unpartial } from 'type-plus'
1
+ import { required } from 'type-plus'
2
+ import { unpartial } from 'unpartial'
2
3
  import { createConsoleLogReporter } from './console.js'
3
4
  import { formatLogLevel } from './formatter.js'
4
5
  import { toInspectLogEntry } from './platform.js'