@hamak/logging 0.5.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 (92) hide show
  1. package/README.md +252 -0
  2. package/dist/api/index.d.ts +12 -0
  3. package/dist/api/index.d.ts.map +1 -0
  4. package/dist/api/index.js +14 -0
  5. package/dist/api/interfaces/index.d.ts +4 -0
  6. package/dist/api/interfaces/index.d.ts.map +1 -0
  7. package/dist/api/interfaces/index.js +3 -0
  8. package/dist/api/interfaces/logger.d.ts +105 -0
  9. package/dist/api/interfaces/logger.d.ts.map +1 -0
  10. package/dist/api/interfaces/logger.js +1 -0
  11. package/dist/api/interfaces/manager.d.ts +120 -0
  12. package/dist/api/interfaces/manager.d.ts.map +1 -0
  13. package/dist/api/interfaces/manager.js +1 -0
  14. package/dist/api/interfaces/transport.d.ts +97 -0
  15. package/dist/api/interfaces/transport.d.ts.map +1 -0
  16. package/dist/api/interfaces/transport.js +1 -0
  17. package/dist/api/tokens/index.d.ts +2 -0
  18. package/dist/api/tokens/index.d.ts.map +1 -0
  19. package/dist/api/tokens/index.js +1 -0
  20. package/dist/api/tokens/service-tokens.d.ts +51 -0
  21. package/dist/api/tokens/service-tokens.d.ts.map +1 -0
  22. package/dist/api/tokens/service-tokens.js +42 -0
  23. package/dist/api/types/index.d.ts +3 -0
  24. package/dist/api/types/index.d.ts.map +1 -0
  25. package/dist/api/types/index.js +2 -0
  26. package/dist/api/types/log-config.d.ts +72 -0
  27. package/dist/api/types/log-config.d.ts.map +1 -0
  28. package/dist/api/types/log-config.js +1 -0
  29. package/dist/api/types/log-entry.d.ts +64 -0
  30. package/dist/api/types/log-entry.d.ts.map +1 -0
  31. package/dist/api/types/log-entry.js +12 -0
  32. package/dist/impl/core/context-logger.d.ts +26 -0
  33. package/dist/impl/core/context-logger.d.ts.map +1 -0
  34. package/dist/impl/core/context-logger.js +102 -0
  35. package/dist/impl/core/index.d.ts +3 -0
  36. package/dist/impl/core/index.d.ts.map +1 -0
  37. package/dist/impl/core/index.js +2 -0
  38. package/dist/impl/core/log-manager.d.ts +41 -0
  39. package/dist/impl/core/log-manager.d.ts.map +1 -0
  40. package/dist/impl/core/log-manager.js +278 -0
  41. package/dist/impl/formatters/dev-formatter.d.ts +20 -0
  42. package/dist/impl/formatters/dev-formatter.d.ts.map +1 -0
  43. package/dist/impl/formatters/dev-formatter.js +145 -0
  44. package/dist/impl/formatters/index.d.ts +3 -0
  45. package/dist/impl/formatters/index.d.ts.map +1 -0
  46. package/dist/impl/formatters/index.js +2 -0
  47. package/dist/impl/formatters/json-formatter.d.ts +24 -0
  48. package/dist/impl/formatters/json-formatter.d.ts.map +1 -0
  49. package/dist/impl/formatters/json-formatter.js +70 -0
  50. package/dist/impl/index.d.ts +16 -0
  51. package/dist/impl/index.d.ts.map +1 -0
  52. package/dist/impl/index.js +19 -0
  53. package/dist/impl/plugin/index.d.ts +2 -0
  54. package/dist/impl/plugin/index.d.ts.map +1 -0
  55. package/dist/impl/plugin/index.js +1 -0
  56. package/dist/impl/plugin/logging-plugin-factory.d.ts +37 -0
  57. package/dist/impl/plugin/logging-plugin-factory.d.ts.map +1 -0
  58. package/dist/impl/plugin/logging-plugin-factory.js +112 -0
  59. package/dist/impl/transports/console-transport.d.ts +16 -0
  60. package/dist/impl/transports/console-transport.d.ts.map +1 -0
  61. package/dist/impl/transports/console-transport.js +55 -0
  62. package/dist/impl/transports/index.d.ts +2 -0
  63. package/dist/impl/transports/index.d.ts.map +1 -0
  64. package/dist/impl/transports/index.js +1 -0
  65. package/dist/impl/utils/console-interceptor.d.ts +36 -0
  66. package/dist/impl/utils/console-interceptor.d.ts.map +1 -0
  67. package/dist/impl/utils/console-interceptor.js +121 -0
  68. package/dist/impl/utils/event-emitter.d.ts +11 -0
  69. package/dist/impl/utils/event-emitter.d.ts.map +1 -0
  70. package/dist/impl/utils/event-emitter.js +44 -0
  71. package/dist/impl/utils/index.d.ts +3 -0
  72. package/dist/impl/utils/index.d.ts.map +1 -0
  73. package/dist/impl/utils/index.js +2 -0
  74. package/dist/index.d.ts +15 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +14 -0
  77. package/dist/spi/formatter/formatter-provider.d.ts +67 -0
  78. package/dist/spi/formatter/formatter-provider.d.ts.map +1 -0
  79. package/dist/spi/formatter/formatter-provider.js +1 -0
  80. package/dist/spi/formatter/index.d.ts +2 -0
  81. package/dist/spi/formatter/index.d.ts.map +1 -0
  82. package/dist/spi/formatter/index.js +1 -0
  83. package/dist/spi/index.d.ts +12 -0
  84. package/dist/spi/index.d.ts.map +1 -0
  85. package/dist/spi/index.js +12 -0
  86. package/dist/spi/transport/index.d.ts +2 -0
  87. package/dist/spi/transport/index.d.ts.map +1 -0
  88. package/dist/spi/transport/index.js +1 -0
  89. package/dist/spi/transport/transport-provider.d.ts +89 -0
  90. package/dist/spi/transport/transport-provider.d.ts.map +1 -0
  91. package/dist/spi/transport/transport-provider.js +1 -0
  92. package/package.json +65 -0
@@ -0,0 +1,112 @@
1
+ import { LOG_MANAGER_TOKEN, LOGGER_TOKEN, LOG_CONFIG_TOKEN } from '../../api/index';
2
+ import { LogManager } from '../core/log-manager';
3
+ import { ConsoleTransport } from '../transports/console-transport';
4
+ import { DevFormatter } from '../formatters/dev-formatter';
5
+ import { JsonFormatter } from '../formatters/json-formatter';
6
+ import { ConsoleInterceptor } from '../utils/console-interceptor';
7
+ /**
8
+ * Create a logging plugin for the microkernel
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { createLoggingPlugin } from '@hamak/logging-impl';
13
+ *
14
+ * const loggingPlugin = createLoggingPlugin({
15
+ * globalLevel: LogLevel.DEBUG,
16
+ * pluginLevels: {
17
+ * 'my-plugin': LogLevel.TRACE
18
+ * }
19
+ * });
20
+ *
21
+ * const host = createHost({
22
+ * plugins: [loggingPlugin, myPlugin]
23
+ * });
24
+ * ```
25
+ */
26
+ export function createLoggingPlugin(config = {}) {
27
+ let logManager;
28
+ let rootLogger;
29
+ let consoleInterceptor;
30
+ // Determine environment
31
+ const isDevelopment = typeof process !== 'undefined'
32
+ ? process.env.NODE_ENV === 'development'
33
+ : true;
34
+ const defaultConfig = {
35
+ globalLevel: isDevelopment ? 1 : 2, // DEBUG in dev, INFO in prod
36
+ bufferSize: 1000,
37
+ flushInterval: 5000,
38
+ devFormatter: isDevelopment,
39
+ interceptConsole: true, // Enabled by default
40
+ pluginLevels: {},
41
+ moduleLevels: {},
42
+ ...config,
43
+ };
44
+ return {
45
+ async initialize(ctx) {
46
+ // Create log manager
47
+ logManager = new LogManager(defaultConfig);
48
+ rootLogger = logManager.createLogger({ plugin: 'logging', module: 'plugin' });
49
+ // Register console transport
50
+ const formatter = defaultConfig.devFormatter
51
+ ? new DevFormatter({
52
+ colors: true,
53
+ emojis: true,
54
+ timestamps: true,
55
+ showContext: true,
56
+ })
57
+ : new JsonFormatter({ pretty: isDevelopment });
58
+ logManager.registerTransport(new ConsoleTransport(formatter), {
59
+ id: 'console',
60
+ enabled: true,
61
+ minLevel: defaultConfig.globalLevel,
62
+ });
63
+ // Register services via DI
64
+ ctx.provide({ provide: LOG_MANAGER_TOKEN, useValue: logManager });
65
+ ctx.provide({ provide: LOG_CONFIG_TOKEN, useValue: defaultConfig });
66
+ // Provide logger factory
67
+ ctx.provide({
68
+ provide: LOGGER_TOKEN,
69
+ useFactory: (pluginName) => {
70
+ return logManager.createLogger({ plugin: pluginName });
71
+ },
72
+ deps: [],
73
+ });
74
+ rootLogger.info('Logging plugin initialized', {
75
+ globalLevel: defaultConfig.globalLevel,
76
+ formatter: defaultConfig.devFormatter ? 'dev' : 'json',
77
+ tags: ['initialization'],
78
+ });
79
+ },
80
+ async activate(ctx) {
81
+ // Bridge microkernel events to logging
82
+ ctx.hooks.on('plugin:error', ({ plugin, error }) => {
83
+ const logger = logManager.createLogger({ plugin });
84
+ logger.error('Plugin error', error);
85
+ });
86
+ ctx.hooks.on('host:activated', () => {
87
+ rootLogger.info('Microkernel host activated', { tags: ['lifecycle'] });
88
+ });
89
+ // Intercept console methods if enabled
90
+ if (defaultConfig.interceptConsole) {
91
+ consoleInterceptor = new ConsoleInterceptor(logManager);
92
+ consoleInterceptor.intercept();
93
+ rootLogger.debug('Console interception enabled', { tags: ['console'] });
94
+ }
95
+ // Emit logging ready event
96
+ ctx.hooks.emit('logging:ready', { logManager });
97
+ rootLogger.info('Logging plugin activated', {
98
+ tags: ['lifecycle'],
99
+ interceptConsole: defaultConfig.interceptConsole,
100
+ });
101
+ },
102
+ async deactivate() {
103
+ rootLogger.info('Logging plugin deactivating', { tags: ['lifecycle'] });
104
+ // Restore original console methods
105
+ if (consoleInterceptor) {
106
+ consoleInterceptor.restore();
107
+ rootLogger.debug('Console interception disabled', { tags: ['console'] });
108
+ }
109
+ await logManager.destroy();
110
+ },
111
+ };
112
+ }
@@ -0,0 +1,16 @@
1
+ import type { ILogTransport, ILogFormatter, LogEntry } from '../../api/index';
2
+ /**
3
+ * Console transport
4
+ *
5
+ * Outputs logs to the browser console or Node.js console.
6
+ * Supports formatting via pluggable formatters.
7
+ */
8
+ export declare class ConsoleTransport implements ILogTransport {
9
+ private formatter;
10
+ readonly id = "console";
11
+ readonly name = "Console Transport";
12
+ constructor(formatter: ILogFormatter);
13
+ log(entry: LogEntry): void;
14
+ onError(error: Error): void;
15
+ }
16
+ //# sourceMappingURL=console-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-transport.d.ts","sourceRoot":"","sources":["../../../src/impl/transports/console-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE9E;;;;;GAKG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAIxC,OAAO,CAAC,SAAS;IAH7B,QAAQ,CAAC,EAAE,aAAa;IACxB,QAAQ,CAAC,IAAI,uBAAuB;gBAEhB,SAAS,EAAE,aAAa;IAE5C,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IA8B1B,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CAG5B"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Console transport
3
+ *
4
+ * Outputs logs to the browser console or Node.js console.
5
+ * Supports formatting via pluggable formatters.
6
+ */
7
+ export class ConsoleTransport {
8
+ constructor(formatter) {
9
+ Object.defineProperty(this, "formatter", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: formatter
14
+ });
15
+ Object.defineProperty(this, "id", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: 'console'
20
+ });
21
+ Object.defineProperty(this, "name", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: 'Console Transport'
26
+ });
27
+ }
28
+ log(entry) {
29
+ const formatted = this.formatter.format(entry);
30
+ switch (entry.level) {
31
+ case 0: // TRACE
32
+ case 1: // DEBUG
33
+ console.debug(formatted);
34
+ break;
35
+ case 2: // INFO
36
+ console.info(formatted);
37
+ break;
38
+ case 3: // WARN
39
+ console.warn(formatted);
40
+ break;
41
+ case 4: // ERROR
42
+ case 5: // FATAL
43
+ console.error(formatted);
44
+ if (entry.metadata?.error) {
45
+ console.error(entry.metadata.error);
46
+ }
47
+ break;
48
+ default:
49
+ console.log(formatted);
50
+ }
51
+ }
52
+ onError(error) {
53
+ console.error('[ConsoleTransport] Error:', error);
54
+ }
55
+ }
@@ -0,0 +1,2 @@
1
+ export * from './console-transport';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/impl/transports/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './console-transport';
@@ -0,0 +1,36 @@
1
+ import type { ILogManager } from '../../api/index';
2
+ /**
3
+ * Console interceptor that routes console methods through the logging system
4
+ *
5
+ * By default, this is enabled. Set `interceptConsole: false` in LoggingPluginConfig to disable.
6
+ */
7
+ export declare class ConsoleInterceptor {
8
+ private logManager;
9
+ private originalConsole;
10
+ private isIntercepting;
11
+ constructor(logManager: ILogManager);
12
+ /**
13
+ * Start intercepting console methods
14
+ */
15
+ intercept(): void;
16
+ /**
17
+ * Stop intercepting and restore original console methods
18
+ */
19
+ restore(): void;
20
+ /**
21
+ * Get original console for direct access
22
+ */
23
+ getOriginalConsole(): {
24
+ log: typeof console.log;
25
+ debug: typeof console.debug;
26
+ info: typeof console.info;
27
+ warn: typeof console.warn;
28
+ error: typeof console.error;
29
+ trace: typeof console.trace;
30
+ };
31
+ /**
32
+ * Format console arguments into a single message
33
+ */
34
+ private formatMessage;
35
+ }
36
+ //# sourceMappingURL=console-interceptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-interceptor.d.ts","sourceRoot":"","sources":["../../../src/impl/utils/console-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;GAIG;AACH,qBAAa,kBAAkB;IAYjB,OAAO,CAAC,UAAU;IAX9B,OAAO,CAAC,eAAe,CAOrB;IAEF,OAAO,CAAC,cAAc,CAAS;gBAEX,UAAU,EAAE,WAAW;IAY3C;;OAEG;IACH,SAAS,IAAI,IAAI;IAiDjB;;OAEG;IACH,OAAO,IAAI,IAAI;IAef;;OAEG;IACH,kBAAkB;aA/FX,OAAO,OAAO,CAAC,GAAG;eAChB,OAAO,OAAO,CAAC,KAAK;cACrB,OAAO,OAAO,CAAC,IAAI;cACnB,OAAO,OAAO,CAAC,IAAI;eAClB,OAAO,OAAO,CAAC,KAAK;eACpB,OAAO,OAAO,CAAC,KAAK;;IA8F7B;;OAEG;IACH,OAAO,CAAC,aAAa;CAiBtB"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Console interceptor that routes console methods through the logging system
3
+ *
4
+ * By default, this is enabled. Set `interceptConsole: false` in LoggingPluginConfig to disable.
5
+ */
6
+ export class ConsoleInterceptor {
7
+ constructor(logManager) {
8
+ Object.defineProperty(this, "logManager", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: logManager
13
+ });
14
+ Object.defineProperty(this, "originalConsole", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: void 0
19
+ });
20
+ Object.defineProperty(this, "isIntercepting", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: false
25
+ });
26
+ // Store original console methods
27
+ this.originalConsole = {
28
+ log: console.log.bind(console),
29
+ debug: console.debug.bind(console),
30
+ info: console.info.bind(console),
31
+ warn: console.warn.bind(console),
32
+ error: console.error.bind(console),
33
+ trace: console.trace.bind(console),
34
+ };
35
+ }
36
+ /**
37
+ * Start intercepting console methods
38
+ */
39
+ intercept() {
40
+ if (this.isIntercepting) {
41
+ return;
42
+ }
43
+ const logger = this.logManager.createLogger({
44
+ plugin: 'console-interceptor',
45
+ module: 'global'
46
+ });
47
+ // Intercept console.log
48
+ console.log = (...args) => {
49
+ logger.info(this.formatMessage(args));
50
+ };
51
+ // Intercept console.debug
52
+ console.debug = (...args) => {
53
+ logger.debug(this.formatMessage(args));
54
+ };
55
+ // Intercept console.info
56
+ console.info = (...args) => {
57
+ logger.info(this.formatMessage(args));
58
+ };
59
+ // Intercept console.warn
60
+ console.warn = (...args) => {
61
+ logger.warn(this.formatMessage(args));
62
+ };
63
+ // Intercept console.error
64
+ console.error = (...args) => {
65
+ const message = this.formatMessage(args);
66
+ const error = args.find(arg => arg instanceof Error);
67
+ logger.error(message, error);
68
+ };
69
+ // Intercept console.trace
70
+ console.trace = (...args) => {
71
+ const message = this.formatMessage(args);
72
+ logger.debug(message, {
73
+ stack: new Error().stack,
74
+ tags: ['trace']
75
+ });
76
+ };
77
+ this.isIntercepting = true;
78
+ }
79
+ /**
80
+ * Stop intercepting and restore original console methods
81
+ */
82
+ restore() {
83
+ if (!this.isIntercepting) {
84
+ return;
85
+ }
86
+ console.log = this.originalConsole.log;
87
+ console.debug = this.originalConsole.debug;
88
+ console.info = this.originalConsole.info;
89
+ console.warn = this.originalConsole.warn;
90
+ console.error = this.originalConsole.error;
91
+ console.trace = this.originalConsole.trace;
92
+ this.isIntercepting = false;
93
+ }
94
+ /**
95
+ * Get original console for direct access
96
+ */
97
+ getOriginalConsole() {
98
+ return this.originalConsole;
99
+ }
100
+ /**
101
+ * Format console arguments into a single message
102
+ */
103
+ formatMessage(args) {
104
+ return args
105
+ .map(arg => {
106
+ if (typeof arg === 'string') {
107
+ return arg;
108
+ }
109
+ if (arg instanceof Error) {
110
+ return `${arg.name}: ${arg.message}`;
111
+ }
112
+ try {
113
+ return JSON.stringify(arg);
114
+ }
115
+ catch {
116
+ return String(arg);
117
+ }
118
+ })
119
+ .join(' ');
120
+ }
121
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Simple event emitter for internal use
3
+ */
4
+ export declare class EventEmitter {
5
+ private listeners;
6
+ on(event: string, handler: Function): void;
7
+ off(event: string, handler: Function): void;
8
+ emit(event: string, ...args: any[]): void;
9
+ clear(): void;
10
+ }
11
+ //# sourceMappingURL=event-emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../../../src/impl/utils/event-emitter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAoC;IAErD,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI;IAO1C,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI;IAU3C,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAazC,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Simple event emitter for internal use
3
+ */
4
+ export class EventEmitter {
5
+ constructor() {
6
+ Object.defineProperty(this, "listeners", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: new Map()
11
+ });
12
+ }
13
+ on(event, handler) {
14
+ if (!this.listeners.has(event)) {
15
+ this.listeners.set(event, new Set());
16
+ }
17
+ this.listeners.get(event).add(handler);
18
+ }
19
+ off(event, handler) {
20
+ const handlers = this.listeners.get(event);
21
+ if (handlers) {
22
+ handlers.delete(handler);
23
+ if (handlers.size === 0) {
24
+ this.listeners.delete(event);
25
+ }
26
+ }
27
+ }
28
+ emit(event, ...args) {
29
+ const handlers = this.listeners.get(event);
30
+ if (handlers) {
31
+ handlers.forEach(handler => {
32
+ try {
33
+ handler(...args);
34
+ }
35
+ catch (error) {
36
+ console.error(`[EventEmitter] Error in handler for '${event}':`, error);
37
+ }
38
+ });
39
+ }
40
+ }
41
+ clear() {
42
+ this.listeners.clear();
43
+ }
44
+ }
@@ -0,0 +1,3 @@
1
+ export * from './event-emitter';
2
+ export * from './console-interceptor';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/impl/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './event-emitter';
2
+ export * from './console-interceptor';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @hamak/logging
3
+ *
4
+ * Complete logging system with API, SPI, and implementation.
5
+ *
6
+ * Usage:
7
+ * - `@hamak/logging/api` - Pure interfaces and tokens
8
+ * - `@hamak/logging/spi` - Extension points for custom transports/formatters
9
+ * - `@hamak/logging` - Full implementation
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ export * from './impl/index';
14
+ export type { ITransportProvider, TransportRegistration, IFormatterProvider, FormatterRegistration, } from './spi/index';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,cAAc,cAAc,CAAC;AAG7B,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @hamak/logging
3
+ *
4
+ * Complete logging system with API, SPI, and implementation.
5
+ *
6
+ * Usage:
7
+ * - `@hamak/logging/api` - Pure interfaces and tokens
8
+ * - `@hamak/logging/spi` - Extension points for custom transports/formatters
9
+ * - `@hamak/logging` - Full implementation
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ // Export everything from impl (which re-exports api)
14
+ export * from './impl/index';
@@ -0,0 +1,67 @@
1
+ import type { ILogFormatter } from '../../api/index';
2
+ /**
3
+ * Formatter Provider Interface
4
+ *
5
+ * Allows plugins to contribute custom log formatters.
6
+ * Formatters convert LogEntry objects into formatted output.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * export class MyFormatterProvider implements IFormatterProvider {
11
+ * readonly id = 'my-formatter';
12
+ * readonly name = 'My Custom Formatter';
13
+ *
14
+ * create(config?: MyFormatterConfig): ILogFormatter {
15
+ * return new MyFormatter(config);
16
+ * }
17
+ * }
18
+ * ```
19
+ */
20
+ export interface IFormatterProvider {
21
+ /**
22
+ * Unique identifier for this formatter provider
23
+ */
24
+ readonly id: string;
25
+ /**
26
+ * Human-readable name
27
+ */
28
+ readonly name: string;
29
+ /**
30
+ * Description of the formatting style
31
+ */
32
+ readonly description?: string;
33
+ /**
34
+ * Create a formatter instance with the given configuration
35
+ *
36
+ * @param config Optional formatter-specific configuration
37
+ * @returns A configured formatter instance
38
+ */
39
+ create(config?: any): ILogFormatter;
40
+ /**
41
+ * Validate formatter-specific configuration
42
+ * Called before creating the formatter
43
+ *
44
+ * @param config Configuration to validate
45
+ * @returns true if valid, false otherwise
46
+ */
47
+ validateConfig?(config: any): boolean;
48
+ /**
49
+ * Get configuration schema for documentation/UI
50
+ *
51
+ * @returns JSON Schema or similar
52
+ */
53
+ getConfigSchema?(): any;
54
+ }
55
+ /**
56
+ * Formatter registration
57
+ * Used when plugins contribute formatters
58
+ */
59
+ export interface FormatterRegistration {
60
+ /** The formatter provider */
61
+ provider: IFormatterProvider;
62
+ /** Formatter configuration */
63
+ config?: any;
64
+ /** Plugin that registered this formatter */
65
+ plugin?: string;
66
+ }
67
+ //# sourceMappingURL=formatter-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter-provider.d.ts","sourceRoot":"","sources":["../../../src/spi/formatter/formatter-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,aAAa,CAAC;IAEpC;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC;IAEtC;;;;OAIG;IACH,eAAe,CAAC,IAAI,GAAG,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,6BAA6B;IAC7B,QAAQ,EAAE,kBAAkB,CAAC;IAE7B,8BAA8B;IAC9B,MAAM,CAAC,EAAE,GAAG,CAAC;IAEb,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './formatter-provider';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spi/formatter/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './formatter-provider';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @hamak/logging/spi
3
+ *
4
+ * Service Provider Interface for the logging system.
5
+ * Provides extension points for custom transports and formatters.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export * from './transport/index';
10
+ export * from './formatter/index';
11
+ export type { ILogger, ILogTransport, ILogFormatter, ILogManager, LogLevel, LogEntry, LogContext, LogMetadata, TransportConfig, LogManagerConfig, } from '../api/index';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spi/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,cAAc,mBAAmB,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAGlC,YAAY,EACV,OAAO,EACP,aAAa,EACb,aAAa,EACb,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,WAAW,EACX,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @hamak/logging/spi
3
+ *
4
+ * Service Provider Interface for the logging system.
5
+ * Provides extension points for custom transports and formatters.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ // Export transport provider interfaces
10
+ export * from './transport/index';
11
+ // Export formatter provider interfaces
12
+ export * from './formatter/index';
@@ -0,0 +1,2 @@
1
+ export * from './transport-provider';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spi/transport/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './transport-provider';