@nyssa-ai/logging 0.0.0-stage → 0.2.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 (78) hide show
  1. package/README.md +50 -2
  2. package/dist/LogLevel.d.ts +4 -0
  3. package/dist/LogLevel.d.ts.map +1 -0
  4. package/dist/LogLevel.js +50 -0
  5. package/dist/LogLevel.js.map +1 -0
  6. package/dist/Logger.d.ts +11 -0
  7. package/dist/Logger.d.ts.map +1 -0
  8. package/dist/Logger.js +12 -0
  9. package/dist/Logger.js.map +1 -0
  10. package/dist/LoggerProvider.d.ts +6 -0
  11. package/dist/LoggerProvider.d.ts.map +1 -0
  12. package/dist/LoggerProvider.js +7 -0
  13. package/dist/LoggerProvider.js.map +1 -0
  14. package/dist/configuration/CompositeLogger.d.ts +14 -0
  15. package/dist/configuration/CompositeLogger.d.ts.map +1 -0
  16. package/dist/configuration/CompositeLogger.js +51 -0
  17. package/dist/configuration/CompositeLogger.js.map +1 -0
  18. package/dist/configuration/LoggingBuilder.d.ts +23 -0
  19. package/dist/configuration/LoggingBuilder.d.ts.map +1 -0
  20. package/dist/configuration/LoggingBuilder.js +89 -0
  21. package/dist/configuration/LoggingBuilder.js.map +1 -0
  22. package/dist/configuration/createNyssaLogging.d.ts +5 -0
  23. package/dist/configuration/createNyssaLogging.d.ts.map +1 -0
  24. package/dist/configuration/createNyssaLogging.js +13 -0
  25. package/dist/configuration/createNyssaLogging.js.map +1 -0
  26. package/dist/consoleLogging/ConsoleOutputLogger.d.ts +16 -0
  27. package/dist/consoleLogging/ConsoleOutputLogger.d.ts.map +1 -0
  28. package/dist/consoleLogging/ConsoleOutputLogger.js +81 -0
  29. package/dist/consoleLogging/ConsoleOutputLogger.js.map +1 -0
  30. package/dist/consoleLogging/ConsoleOutputLoggerProvider.d.ts +9 -0
  31. package/dist/consoleLogging/ConsoleOutputLoggerProvider.d.ts.map +1 -0
  32. package/dist/consoleLogging/ConsoleOutputLoggerProvider.js +20 -0
  33. package/dist/consoleLogging/ConsoleOutputLoggerProvider.js.map +1 -0
  34. package/dist/consoleLogging/StderrOutputLogger.d.ts +16 -0
  35. package/dist/consoleLogging/StderrOutputLogger.d.ts.map +1 -0
  36. package/dist/consoleLogging/StderrOutputLogger.js +81 -0
  37. package/dist/consoleLogging/StderrOutputLogger.js.map +1 -0
  38. package/dist/consoleLogging/StderrOutputLoggerProvider.d.ts +9 -0
  39. package/dist/consoleLogging/StderrOutputLoggerProvider.d.ts.map +1 -0
  40. package/dist/consoleLogging/StderrOutputLoggerProvider.js +20 -0
  41. package/dist/consoleLogging/StderrOutputLoggerProvider.js.map +1 -0
  42. package/dist/fileLogging/Clock.d.ts +4 -0
  43. package/dist/fileLogging/Clock.d.ts.map +1 -0
  44. package/dist/fileLogging/Clock.js +6 -0
  45. package/dist/fileLogging/Clock.js.map +1 -0
  46. package/dist/fileLogging/JsonFileLogger.d.ts +21 -0
  47. package/dist/fileLogging/JsonFileLogger.d.ts.map +1 -0
  48. package/dist/fileLogging/JsonFileLogger.js +90 -0
  49. package/dist/fileLogging/JsonFileLogger.js.map +1 -0
  50. package/dist/fileLogging/JsonFileLoggerProvider.d.ts +15 -0
  51. package/dist/fileLogging/JsonFileLoggerProvider.d.ts.map +1 -0
  52. package/dist/fileLogging/JsonFileLoggerProvider.js +47 -0
  53. package/dist/fileLogging/JsonFileLoggerProvider.js.map +1 -0
  54. package/dist/fileLogging/LogFile.d.ts +24 -0
  55. package/dist/fileLogging/LogFile.d.ts.map +1 -0
  56. package/dist/fileLogging/LogFile.js +179 -0
  57. package/dist/fileLogging/LogFile.js.map +1 -0
  58. package/dist/fileLogging/LogRecord.d.ts +10 -0
  59. package/dist/fileLogging/LogRecord.d.ts.map +1 -0
  60. package/dist/fileLogging/LogRecord.js +12 -0
  61. package/dist/fileLogging/LogRecord.js.map +1 -0
  62. package/dist/fileLogging/LogRecordSerializer.d.ts +5 -0
  63. package/dist/fileLogging/LogRecordSerializer.d.ts.map +1 -0
  64. package/dist/fileLogging/LogRecordSerializer.js +52 -0
  65. package/dist/fileLogging/LogRecordSerializer.js.map +1 -0
  66. package/dist/fileLogging/OwnerOnlyAccess.d.ts +9 -0
  67. package/dist/fileLogging/OwnerOnlyAccess.d.ts.map +1 -0
  68. package/dist/fileLogging/OwnerOnlyAccess.js +78 -0
  69. package/dist/fileLogging/OwnerOnlyAccess.js.map +1 -0
  70. package/dist/fileLogging/StderrDiagnostics.d.ts +8 -0
  71. package/dist/fileLogging/StderrDiagnostics.d.ts.map +1 -0
  72. package/dist/fileLogging/StderrDiagnostics.js +31 -0
  73. package/dist/fileLogging/StderrDiagnostics.js.map +1 -0
  74. package/dist/fileLogging/SystemClock.d.ts +4 -0
  75. package/dist/fileLogging/SystemClock.d.ts.map +1 -0
  76. package/dist/fileLogging/SystemClock.js +10 -0
  77. package/dist/fileLogging/SystemClock.js.map +1 -0
  78. package/package.json +53 -4
package/README.md CHANGED
@@ -1,3 +1,51 @@
1
- # Temporary Holding Version
1
+ # @nyssa-ai/logging
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@nyssa-ai/logging` provides lightweight, operational logging destinations for TypeScript and Node.js systems, matching the operational behavior and JSON schema of `NyssaAI.Logging` (`nyssa-ai-logging-cs`). It delivers essential operational sinks—structured rotating JSON files, owner-only access controls, independent STDERR/STDOUT routing, and fail-safe execution—without introducing heavy dependencies or complex frameworks.
4
+
5
+ * **Rotating JSONL persistence**: Automatically rotates at 10 MiB with 5 numbered backups and 30-day retention.
6
+ * **Clean protocol streams**: Routes diagnostics to STDERR by default while keeping STDOUT unpolluted for machine protocols (e.g. CLI pipes, MCP servers).
7
+ * **Cross-account privacy**: Enforces POSIX 0600 file modes / 0700 directories and Windows DACLs to prevent unauthorized cross-account log reads.
8
+ * **Crash-proof execution**: Degrades gracefully to STDERR diagnostics without throwing exceptions or aborting execution on sink errors.
9
+ * **Zero-ceremony integration**: Provides a fluent configuration builder and an action-taking `Logger` contract for Dependency Injection.
10
+
11
+ ## Simple setup, ordinary logging
12
+
13
+ Register logging during startup, then inject `Logger` into the classes that need it. `createNyssaLogging()` registers standard error output by default, with `Information` and higher levels enabled:
14
+
15
+ ```typescript
16
+ import { createNyssaLogging } from "@nyssa-ai/logging";
17
+
18
+ const logging = createNyssaLogging("logs/service.log")
19
+ .withRotatingJsonLog("logs/application.json")
20
+ .withConsole();
21
+
22
+ const logger = logging.createLogger("OrderService");
23
+ logger.info("Order {OrderId} placed", { OrderId: 1042 }, "OrderPlaced");
24
+ ```
25
+
26
+ ## The JSON file
27
+
28
+ The log file contains one complete JSON object per line matching the .NET record schema:
29
+
30
+ ```json
31
+ {
32
+ "Timestamp": "2026-10-12T14:23:45.123Z",
33
+ "Level": "Information",
34
+ "Message": "Order 1042 placed",
35
+ "Module": "OrderService",
36
+ "Operation": "OrderPlaced",
37
+ "Exception": null,
38
+ "AdditionalFields": {
39
+ "OrderId": 1042
40
+ }
41
+ }
42
+ ```
43
+
44
+ ## Rotation and retention
45
+
46
+ | Setting | Behavior |
47
+ | --- | --- |
48
+ | Rotation threshold | 10 MiB, or 10,485,760 bytes. |
49
+ | Backup count | Up to five numbered backups beside the active file. |
50
+ | Backup names | `service.log.1` is the newest; `service.log.5` is the oldest. |
51
+ | Age limit | Backups older than 30 days are pruned at startup and during rotation. |
@@ -0,0 +1,4 @@
1
+ export type LogLevel = "Trace" | "Debug" | "Information" | "Warning" | "Error" | "Critical" | "None";
2
+ export declare function parseLogLevel(value: string | undefined): LogLevel;
3
+ export declare function isLogLevelEnabled(level: LogLevel, minimumLevel: LogLevel): boolean;
4
+ //# sourceMappingURL=LogLevel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogLevel.d.ts","sourceRoot":"","sources":["../src/LogLevel.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAChB,OAAO,GACP,OAAO,GACP,aAAa,GACb,SAAS,GACT,OAAO,GACP,UAAU,GACV,MAAM,CAAC;AAYX,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CA0BjE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,GAAG,OAAO,CAOlF"}
@@ -0,0 +1,50 @@
1
+ // Responsibility: Define log level values and level severity comparison logic.
2
+ // Public interface:
3
+ // +-- LogLevel
4
+ // +-- isLogLevelEnabled(level, minimumLevel)
5
+ // `-- parseLogLevel(value)
6
+ const LEVEL_SEVERITY = {
7
+ Trace: 0,
8
+ Debug: 1,
9
+ Information: 2,
10
+ Warning: 3,
11
+ Error: 4,
12
+ Critical: 5,
13
+ None: 6
14
+ };
15
+ export function parseLogLevel(value) {
16
+ if (!value) {
17
+ return "Information";
18
+ }
19
+ const normalized = value.trim().toLowerCase();
20
+ switch (normalized) {
21
+ case "trace":
22
+ return "Trace";
23
+ case "debug":
24
+ return "Debug";
25
+ case "information":
26
+ case "info":
27
+ return "Information";
28
+ case "warning":
29
+ case "warn":
30
+ return "Warning";
31
+ case "error":
32
+ return "Error";
33
+ case "critical":
34
+ case "crit":
35
+ return "Critical";
36
+ case "none":
37
+ return "None";
38
+ default:
39
+ return "Information";
40
+ }
41
+ }
42
+ export function isLogLevelEnabled(level, minimumLevel) {
43
+ if (level === "None") {
44
+ return false;
45
+ }
46
+ const levelSeverity = LEVEL_SEVERITY[level] ?? 2;
47
+ const minimumSeverity = LEVEL_SEVERITY[minimumLevel] ?? 2;
48
+ return levelSeverity >= minimumSeverity;
49
+ }
50
+ //# sourceMappingURL=LogLevel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogLevel.js","sourceRoot":"","sources":["../src/LogLevel.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,oBAAoB;AACpB,eAAe;AACf,6CAA6C;AAC7C,2BAA2B;AAW3B,MAAM,cAAc,GAAuC;IACzD,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CAAC;IACR,WAAW,EAAE,CAAC;IACd,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;IACR,QAAQ,EAAE,CAAC;IACX,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,OAAO,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,OAAO,CAAC;QACjB,KAAK,aAAa,CAAC;QACnB,KAAK,MAAM;YACT,OAAO,aAAa,CAAC;QACvB,KAAK,SAAS,CAAC;QACf,KAAK,MAAM;YACT,OAAO,SAAS,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,OAAO,CAAC;QACjB,KAAK,UAAU,CAAC;QAChB,KAAK,MAAM;YACT,OAAO,UAAU,CAAC;QACpB,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,aAAa,CAAC;IACzB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAe,EAAE,YAAsB;IACvE,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,eAAe,GAAG,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1D,OAAO,aAAa,IAAI,eAAe,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { LogLevel } from "./LogLevel.js";
2
+ export interface Logger {
3
+ trace(message: string, fields?: Record<string, unknown>, operation?: string): void;
4
+ debug(message: string, fields?: Record<string, unknown>, operation?: string): void;
5
+ info(message: string, fields?: Record<string, unknown>, operation?: string): void;
6
+ warn(message: string, fields?: Record<string, unknown>, operation?: string): void;
7
+ error(message: string, error?: unknown, fields?: Record<string, unknown>, operation?: string): void;
8
+ critical(message: string, error?: unknown, fields?: Record<string, unknown>, operation?: string): void;
9
+ isEnabled(level: LogLevel): boolean;
10
+ }
11
+ //# sourceMappingURL=Logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../src/Logger.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnF,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnF,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClF,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClF,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvG,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC;CACrC"}
package/dist/Logger.js ADDED
@@ -0,0 +1,12 @@
1
+ // Responsibility: Structured operational logging contract for action-taking classes.
2
+ // Public interface:
3
+ // `-- Logger
4
+ // +-- critical(message, error, fields, operation)
5
+ // +-- debug(message, fields, operation)
6
+ // +-- error(message, error, fields, operation)
7
+ // +-- info(message, fields, operation)
8
+ // +-- isEnabled(level)
9
+ // +-- trace(message, fields, operation)
10
+ // `-- warn(message, fields, operation)
11
+ export {};
12
+ //# sourceMappingURL=Logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../src/Logger.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,oBAAoB;AACpB,aAAa;AACb,sDAAsD;AACtD,4CAA4C;AAC5C,mDAAmD;AACnD,2CAA2C;AAC3C,2BAA2B;AAC3B,4CAA4C;AAC5C,2CAA2C"}
@@ -0,0 +1,6 @@
1
+ import type { Logger } from "./Logger.js";
2
+ export interface LoggerProvider {
3
+ createLogger(categoryName: string): Logger;
4
+ dispose(): void;
5
+ }
6
+ //# sourceMappingURL=LoggerProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoggerProvider.d.ts","sourceRoot":"","sources":["../src/LoggerProvider.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C,OAAO,IAAI,IAAI,CAAC;CACjB"}
@@ -0,0 +1,7 @@
1
+ // Responsibility: Factory and lifecycle interface for creating category-scoped loggers.
2
+ // Public interface:
3
+ // `-- LoggerProvider
4
+ // +-- createLogger(categoryName)
5
+ // `-- dispose()
6
+ export {};
7
+ //# sourceMappingURL=LoggerProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoggerProvider.js","sourceRoot":"","sources":["../src/LoggerProvider.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,oBAAoB;AACpB,qBAAqB;AACrB,qCAAqC;AACrC,oBAAoB"}
@@ -0,0 +1,14 @@
1
+ import type { Logger } from "../Logger.js";
2
+ import type { LogLevel } from "../LogLevel.js";
3
+ export declare class CompositeLogger {
4
+ private readonly loggers;
5
+ constructor(loggers: readonly Logger[]);
6
+ isEnabled(level: LogLevel): boolean;
7
+ trace(message: string, fields?: Record<string, unknown>, operation?: string): void;
8
+ debug(message: string, fields?: Record<string, unknown>, operation?: string): void;
9
+ info(message: string, fields?: Record<string, unknown>, operation?: string): void;
10
+ warn(message: string, fields?: Record<string, unknown>, operation?: string): void;
11
+ error(message: string, error?: unknown, fields?: Record<string, unknown>, operation?: string): void;
12
+ critical(message: string, error?: unknown, fields?: Record<string, unknown>, operation?: string): void;
13
+ }
14
+ //# sourceMappingURL=CompositeLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompositeLogger.d.ts","sourceRoot":"","sources":["../../src/configuration/CompositeLogger.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;gBAEzB,OAAO,EAAE,SAAS,MAAM,EAAE;IAItC,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAInC,KAAK,CACV,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAMA,KAAK,CACV,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAMA,IAAI,CACT,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAMA,IAAI,CACT,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAMA,KAAK,CACV,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAMA,QAAQ,CACb,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;CAKR"}
@@ -0,0 +1,51 @@
1
+ // Responsibility: Dispatch structured log messages to multiple underlying logger instances.
2
+ // Public interface:
3
+ // `-- CompositeLogger
4
+ // +-- critical(message, error, fields, operation)
5
+ // +-- debug(message, fields, operation)
6
+ // +-- error(message, error, fields, operation)
7
+ // +-- info(message, fields, operation)
8
+ // +-- isEnabled(level)
9
+ // +-- new(loggers)
10
+ // +-- trace(message, fields, operation)
11
+ // `-- warn(message, fields, operation)
12
+ export class CompositeLogger {
13
+ loggers;
14
+ constructor(loggers) {
15
+ this.loggers = loggers;
16
+ }
17
+ isEnabled(level) {
18
+ return this.loggers.some(logger => logger.isEnabled(level));
19
+ }
20
+ trace(message, fields, operation) {
21
+ for (const logger of this.loggers) {
22
+ logger.trace(message, fields, operation);
23
+ }
24
+ }
25
+ debug(message, fields, operation) {
26
+ for (const logger of this.loggers) {
27
+ logger.debug(message, fields, operation);
28
+ }
29
+ }
30
+ info(message, fields, operation) {
31
+ for (const logger of this.loggers) {
32
+ logger.info(message, fields, operation);
33
+ }
34
+ }
35
+ warn(message, fields, operation) {
36
+ for (const logger of this.loggers) {
37
+ logger.warn(message, fields, operation);
38
+ }
39
+ }
40
+ error(message, error, fields, operation) {
41
+ for (const logger of this.loggers) {
42
+ logger.error(message, error, fields, operation);
43
+ }
44
+ }
45
+ critical(message, error, fields, operation) {
46
+ for (const logger of this.loggers) {
47
+ logger.critical(message, error, fields, operation);
48
+ }
49
+ }
50
+ }
51
+ //# sourceMappingURL=CompositeLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompositeLogger.js","sourceRoot":"","sources":["../../src/configuration/CompositeLogger.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,oBAAoB;AACpB,sBAAsB;AACtB,sDAAsD;AACtD,4CAA4C;AAC5C,mDAAmD;AACnD,2CAA2C;AAC3C,2BAA2B;AAC3B,uBAAuB;AACvB,4CAA4C;AAC5C,2CAA2C;AAK3C,MAAM,OAAO,eAAe;IACT,OAAO,CAAoB;IAE5C,YAAmB,OAA0B;QAC3C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,SAAS,CAAC,KAAe;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9D,CAAC;IAEM,KAAK,CACV,OAAe,EACf,MAAgC,EAChC,SAAkB;QAElB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAEM,KAAK,CACV,OAAe,EACf,MAAgC,EAChC,SAAkB;QAElB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAEM,IAAI,CACT,OAAe,EACf,MAAgC,EAChC,SAAkB;QAElB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAEM,IAAI,CACT,OAAe,EACf,MAAgC,EAChC,SAAkB;QAElB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAEM,KAAK,CACV,OAAe,EACf,KAAe,EACf,MAAgC,EAChC,SAAkB;QAElB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAEM,QAAQ,CACb,OAAe,EACf,KAAe,EACf,MAAgC,EAChC,SAAkB;QAElB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ import type { Logger } from "../Logger.js";
2
+ import type { LoggerProvider } from "../LoggerProvider.js";
3
+ import type { LogLevel } from "../LogLevel.js";
4
+ import type { Clock } from "../fileLogging/Clock.js";
5
+ export declare class LoggingBuilder {
6
+ private minimumLevel;
7
+ private readonly clock;
8
+ private readonly providers;
9
+ private hasStderr;
10
+ private hasConsole;
11
+ private disposed;
12
+ constructor(minimumLevel?: LogLevel, clock?: Clock);
13
+ setMinimumLevel(level: LogLevel): this;
14
+ withStdErr(minimumLevel?: LogLevel): this;
15
+ withConsole(minimumLevel?: LogLevel): this;
16
+ withRotatingJsonLog(filePath: string, minimumLevel?: LogLevel): this;
17
+ addNyssaJsonFile(filePath: string, minimumLevel?: LogLevel): this;
18
+ addProvider(provider: LoggerProvider): this;
19
+ createLogger(categoryName: string): Logger;
20
+ dispose(): void;
21
+ private addFileDestination;
22
+ }
23
+ //# sourceMappingURL=LoggingBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoggingBuilder.d.ts","sourceRoot":"","sources":["../../src/configuration/LoggingBuilder.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAcrD,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAAW;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwB;IAClD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAS;gBAEN,YAAY,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK;IAKlD,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAKtC,UAAU,CAAC,YAAY,CAAC,EAAE,QAAQ,GAAG,IAAI;IAQzC,WAAW,CAAC,YAAY,CAAC,EAAE,QAAQ,GAAG,IAAI;IAQ1C,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,QAAQ,GAAG,IAAI;IAQpE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,QAAQ,GAAG,IAAI;IAIjE,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAK3C,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAK1C,OAAO,IAAI,IAAI;IAUtB,OAAO,CAAC,kBAAkB;CAW3B"}
@@ -0,0 +1,89 @@
1
+ // Responsibility: Fluent builder for configuring logging destinations and creating loggers.
2
+ // Public interface:
3
+ // `-- LoggingBuilder
4
+ // +-- addNyssaJsonFile(filePath, minimumLevel)
5
+ // +-- addProvider(provider)
6
+ // +-- createLogger(categoryName)
7
+ // +-- dispose()
8
+ // +-- new(minimumLevel, clock)
9
+ // +-- setMinimumLevel(level)
10
+ // +-- withConsole(minimumLevel)
11
+ // +-- withRotatingJsonLog(filePath, minimumLevel)
12
+ // `-- withStdErr(minimumLevel)
13
+ import * as path from "node:path";
14
+ import { SystemClock } from "../fileLogging/SystemClock.js";
15
+ import { JsonFileLoggerProvider } from "../fileLogging/JsonFileLoggerProvider.js";
16
+ import { StderrOutputLoggerProvider } from "../consoleLogging/StderrOutputLoggerProvider.js";
17
+ import { ConsoleOutputLoggerProvider } from "../consoleLogging/ConsoleOutputLoggerProvider.js";
18
+ import { CompositeLogger } from "./CompositeLogger.js";
19
+ function formatUtcDate(date) {
20
+ const y = date.getUTCFullYear();
21
+ const m = String(date.getUTCMonth() + 1).padStart(2, "0");
22
+ const d = String(date.getUTCDate()).padStart(2, "0");
23
+ return `${y}.${m}.${d}`;
24
+ }
25
+ export class LoggingBuilder {
26
+ minimumLevel;
27
+ clock;
28
+ providers = [];
29
+ hasStderr = false;
30
+ hasConsole = false;
31
+ disposed = false;
32
+ constructor(minimumLevel, clock) {
33
+ this.minimumLevel = minimumLevel ?? "Information";
34
+ this.clock = clock ?? new SystemClock();
35
+ }
36
+ setMinimumLevel(level) {
37
+ this.minimumLevel = level;
38
+ return this;
39
+ }
40
+ withStdErr(minimumLevel) {
41
+ if (!this.hasStderr) {
42
+ this.hasStderr = true;
43
+ this.providers.push(new StderrOutputLoggerProvider(minimumLevel ?? this.minimumLevel));
44
+ }
45
+ return this;
46
+ }
47
+ withConsole(minimumLevel) {
48
+ if (!this.hasConsole) {
49
+ this.hasConsole = true;
50
+ this.providers.push(new ConsoleOutputLoggerProvider(minimumLevel ?? this.minimumLevel));
51
+ }
52
+ return this;
53
+ }
54
+ withRotatingJsonLog(filePath, minimumLevel) {
55
+ const directory = path.dirname(filePath);
56
+ const effectiveDir = !directory || directory === "." ? process.cwd() : directory;
57
+ const date = formatUtcDate(this.clock.now());
58
+ const destination = path.join(effectiveDir, `${date}-${path.basename(filePath)}`);
59
+ return this.addFileDestination(destination, minimumLevel);
60
+ }
61
+ addNyssaJsonFile(filePath, minimumLevel) {
62
+ return this.addFileDestination(filePath, minimumLevel);
63
+ }
64
+ addProvider(provider) {
65
+ this.providers.push(provider);
66
+ return this;
67
+ }
68
+ createLogger(categoryName) {
69
+ const loggers = this.providers.map(p => p.createLogger(categoryName));
70
+ return new CompositeLogger(loggers);
71
+ }
72
+ dispose() {
73
+ if (this.disposed) {
74
+ return;
75
+ }
76
+ this.disposed = true;
77
+ for (const provider of this.providers) {
78
+ provider.dispose();
79
+ }
80
+ }
81
+ addFileDestination(destination, minimumLevel) {
82
+ const provider = JsonFileLoggerProvider.tryCreate(destination, this.clock, minimumLevel ?? this.minimumLevel);
83
+ if (provider !== null) {
84
+ this.providers.push(provider);
85
+ }
86
+ return this;
87
+ }
88
+ }
89
+ //# sourceMappingURL=LoggingBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoggingBuilder.js","sourceRoot":"","sources":["../../src/configuration/LoggingBuilder.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,oBAAoB;AACpB,qBAAqB;AACrB,mDAAmD;AACnD,gCAAgC;AAChC,qCAAqC;AACrC,oBAAoB;AACpB,mCAAmC;AACnC,iCAAiC;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AS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,YAAY,CAAC,YAAoB;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;QACtE,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEM,OAAO;QACZ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACtC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;IAEO,kBAAkB,CAAC,WAAmB,EAAE,YAAuB;QACrE,MAAM,QAAQ,GAAG,sBAAsB,CAAC,SAAS,CAC/C,WAAW,EACX,IAAI,CAAC,KAAK,EACV,YAAY,IAAI,IAAI,CAAC,YAAY,CAClC,CAAC;QACF,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACtB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ import type { Clock } from "../fileLogging/Clock.js";
2
+ import type { LogLevel } from "../LogLevel.js";
3
+ import { LoggingBuilder } from "./LoggingBuilder.js";
4
+ export declare function createNyssaLogging(filePath?: string, minimumLevel?: LogLevel, clock?: Clock): LoggingBuilder;
5
+ //# sourceMappingURL=createNyssaLogging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNyssaLogging.d.ts","sourceRoot":"","sources":["../../src/configuration/createNyssaLogging.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,wBAAgB,kBAAkB,CAChC,QAAQ,CAAC,EAAE,MAAM,EACjB,YAAY,GAAE,QAAwB,EACtC,KAAK,CAAC,EAAE,KAAK,GACZ,cAAc,CAOhB"}
@@ -0,0 +1,13 @@
1
+ // Responsibility: Factory function configuring default Nyssa logging with standard error and optional JSON file.
2
+ // Public interface:
3
+ // `-- createNyssaLogging(filePath, minimumLevel, clock)
4
+ import { LoggingBuilder } from "./LoggingBuilder.js";
5
+ export function createNyssaLogging(filePath, minimumLevel = "Information", clock) {
6
+ const builder = new LoggingBuilder(minimumLevel, clock);
7
+ builder.withStdErr(minimumLevel);
8
+ if (filePath) {
9
+ builder.addNyssaJsonFile(filePath, minimumLevel);
10
+ }
11
+ return builder;
12
+ }
13
+ //# sourceMappingURL=createNyssaLogging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNyssaLogging.js","sourceRoot":"","sources":["../../src/configuration/createNyssaLogging.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,oBAAoB;AACpB,wDAAwD;AAIxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,UAAU,kBAAkB,CAChC,QAAiB,EACjB,eAAyB,aAAa,EACtC,KAAa;IAEb,MAAM,OAAO,GAAG,IAAI,cAAc,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACxD,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACjC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type LogLevel } from "../LogLevel.js";
2
+ export declare class ConsoleOutputLogger {
3
+ private readonly categoryName;
4
+ private readonly minimumLevel;
5
+ constructor(categoryName: string, minimumLevel: LogLevel);
6
+ isEnabled(level: LogLevel): boolean;
7
+ trace(message: string, fields?: Record<string, unknown>, operation?: string): void;
8
+ debug(message: string, fields?: Record<string, unknown>, operation?: string): void;
9
+ info(message: string, fields?: Record<string, unknown>, operation?: string): void;
10
+ warn(message: string, fields?: Record<string, unknown>, operation?: string): void;
11
+ error(message: string, error?: unknown, fields?: Record<string, unknown>, operation?: string): void;
12
+ critical(message: string, error?: unknown, fields?: Record<string, unknown>, operation?: string): void;
13
+ private write;
14
+ private formatTemplate;
15
+ }
16
+ //# sourceMappingURL=ConsoleOutputLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleOutputLogger.d.ts","sourceRoot":"","sources":["../../src/consoleLogging/ConsoleOutputLogger.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAYlE,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAW;gBAErB,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ;IAKxD,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAInC,KAAK,CACV,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,KAAK,CACV,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,IAAI,CACT,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,IAAI,CACT,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,KAAK,CACV,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,QAAQ,CACb,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIP,OAAO,CAAC,KAAK;IA2Bb,OAAO,CAAC,cAAc;CAcvB"}
@@ -0,0 +1,81 @@
1
+ // Responsibility: Output formatted operational log lines to standard output with sink isolation.
2
+ // Public interface:
3
+ // `-- ConsoleOutputLogger
4
+ // +-- critical(message, error, fields, operation)
5
+ // +-- debug(message, fields, operation)
6
+ // +-- error(message, error, fields, operation)
7
+ // +-- info(message, fields, operation)
8
+ // +-- isEnabled(level)
9
+ // +-- new(categoryName, minimumLevel)
10
+ // +-- trace(message, fields, operation)
11
+ // `-- warn(message, fields, operation)
12
+ import * as os from "node:os";
13
+ import { isLogLevelEnabled } from "../LogLevel.js";
14
+ const LEVEL_TAGS = {
15
+ Trace: "trce",
16
+ Debug: "dbug",
17
+ Information: "info",
18
+ Warning: "warn",
19
+ Error: "fail",
20
+ Critical: "crit",
21
+ None: "none"
22
+ };
23
+ export class ConsoleOutputLogger {
24
+ categoryName;
25
+ minimumLevel;
26
+ constructor(categoryName, minimumLevel) {
27
+ this.categoryName = categoryName;
28
+ this.minimumLevel = minimumLevel;
29
+ }
30
+ isEnabled(level) {
31
+ return isLogLevelEnabled(level, this.minimumLevel);
32
+ }
33
+ trace(message, fields, operation) {
34
+ this.write("Trace", message, fields, operation, null);
35
+ }
36
+ debug(message, fields, operation) {
37
+ this.write("Debug", message, fields, operation, null);
38
+ }
39
+ info(message, fields, operation) {
40
+ this.write("Information", message, fields, operation, null);
41
+ }
42
+ warn(message, fields, operation) {
43
+ this.write("Warning", message, fields, operation, null);
44
+ }
45
+ error(message, error, fields, operation) {
46
+ this.write("Error", message, fields, operation, error);
47
+ }
48
+ critical(message, error, fields, operation) {
49
+ this.write("Critical", message, fields, operation, error);
50
+ }
51
+ write(level, message, fields, _operation, error) {
52
+ if (!this.isEnabled(level)) {
53
+ return;
54
+ }
55
+ try {
56
+ const tag = LEVEL_TAGS[level] ?? "info";
57
+ const formatted = this.formatTemplate(message, fields);
58
+ let output = `${tag}: ${this.categoryName}${os.EOL} ${formatted}${os.EOL}`;
59
+ if (error !== undefined && error !== null) {
60
+ const errorText = error instanceof Error ? error.stack ?? error.message : String(error);
61
+ output += ` ${errorText}${os.EOL}`;
62
+ }
63
+ process.stdout.write(output);
64
+ }
65
+ catch {
66
+ // TS-LOG: Sink failures are contained and do not fail the business operation.
67
+ }
68
+ }
69
+ formatTemplate(template, fields) {
70
+ if (!fields || Object.keys(fields).length === 0) {
71
+ return template;
72
+ }
73
+ return template.replace(/\{(\w+)\}/g, (match, key) => {
74
+ if (key in fields && fields[key] !== undefined) {
75
+ return String(fields[key]);
76
+ }
77
+ return match;
78
+ });
79
+ }
80
+ }
81
+ //# sourceMappingURL=ConsoleOutputLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleOutputLogger.js","sourceRoot":"","sources":["../../src/consoleLogging/ConsoleOutputLogger.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,oBAAoB;AACpB,0BAA0B;AAC1B,sDAAsD;AACtD,4CAA4C;AAC5C,mDAAmD;AACnD,2CAA2C;AAC3C,2BAA2B;AAC3B,0CAA0C;AAC1C,4CAA4C;AAC5C,2CAA2C;AAE3C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,iBAAiB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CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChD,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,GAAW,EAAE,EAAE;YAC3D,IAAI,GAAG,IAAI,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7B,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import type { Logger } from "../Logger.js";
2
+ import type { LogLevel } from "../LogLevel.js";
3
+ export declare class ConsoleOutputLoggerProvider {
4
+ private readonly minimumLevel;
5
+ constructor(minimumLevel?: LogLevel);
6
+ createLogger(categoryName: string): Logger;
7
+ dispose(): void;
8
+ }
9
+ //# sourceMappingURL=ConsoleOutputLoggerProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleOutputLoggerProvider.d.ts","sourceRoot":"","sources":["../../src/consoleLogging/ConsoleOutputLoggerProvider.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAW;gBAErB,YAAY,CAAC,EAAE,QAAQ;IAInC,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAI1C,OAAO,IAAI,IAAI;CAGvB"}
@@ -0,0 +1,20 @@
1
+ // Responsibility: Provider for category-scoped standard output loggers.
2
+ // Public interface:
3
+ // `-- ConsoleOutputLoggerProvider
4
+ // +-- createLogger(categoryName)
5
+ // +-- dispose()
6
+ // `-- new(minimumLevel)
7
+ import { ConsoleOutputLogger } from "./ConsoleOutputLogger.js";
8
+ export class ConsoleOutputLoggerProvider {
9
+ minimumLevel;
10
+ constructor(minimumLevel) {
11
+ this.minimumLevel = minimumLevel ?? "Information";
12
+ }
13
+ createLogger(categoryName) {
14
+ return new ConsoleOutputLogger(categoryName, this.minimumLevel);
15
+ }
16
+ dispose() {
17
+ // Stdout requires no resource teardown.
18
+ }
19
+ }
20
+ //# sourceMappingURL=ConsoleOutputLoggerProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleOutputLoggerProvider.js","sourceRoot":"","sources":["../../src/consoleLogging/ConsoleOutputLoggerProvider.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,oBAAoB;AACpB,kCAAkC;AAClC,qCAAqC;AACrC,oBAAoB;AACpB,4BAA4B;AAI5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,OAAO,2BAA2B;IACrB,YAAY,CAAW;IAExC,YAAmB,YAAuB;QACxC,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,aAAa,CAAC;IACpD,CAAC;IAEM,YAAY,CAAC,YAAoB;QACtC,OAAO,IAAI,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;IAEM,OAAO;QACZ,wCAAwC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import { type LogLevel } from "../LogLevel.js";
2
+ export declare class StderrOutputLogger {
3
+ private readonly categoryName;
4
+ private readonly minimumLevel;
5
+ constructor(categoryName: string, minimumLevel: LogLevel);
6
+ isEnabled(level: LogLevel): boolean;
7
+ trace(message: string, fields?: Record<string, unknown>, operation?: string): void;
8
+ debug(message: string, fields?: Record<string, unknown>, operation?: string): void;
9
+ info(message: string, fields?: Record<string, unknown>, operation?: string): void;
10
+ warn(message: string, fields?: Record<string, unknown>, operation?: string): void;
11
+ error(message: string, error?: unknown, fields?: Record<string, unknown>, operation?: string): void;
12
+ critical(message: string, error?: unknown, fields?: Record<string, unknown>, operation?: string): void;
13
+ private write;
14
+ private formatTemplate;
15
+ }
16
+ //# sourceMappingURL=StderrOutputLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StderrOutputLogger.d.ts","sourceRoot":"","sources":["../../src/consoleLogging/StderrOutputLogger.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAYlE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAW;gBAErB,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ;IAKxD,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAInC,KAAK,CACV,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,KAAK,CACV,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,IAAI,CACT,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,IAAI,CACT,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,KAAK,CACV,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAIA,QAAQ,CACb,OAAO,EAA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