@nx-ddd/logging 19.51.0 → 19.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/fesm2022/nx-ddd-logging-base.mjs +0 -51
  2. package/fesm2022/nx-ddd-logging-base.mjs.map +1 -1
  3. package/fesm2022/nx-ddd-logging-console.mjs +35 -13
  4. package/fesm2022/nx-ddd-logging-console.mjs.map +1 -1
  5. package/fesm2022/nx-ddd-logging-factory.mjs +31 -0
  6. package/fesm2022/nx-ddd-logging-factory.mjs.map +1 -0
  7. package/fesm2022/nx-ddd-logging-file.mjs +20 -25
  8. package/fesm2022/nx-ddd-logging-file.mjs.map +1 -1
  9. package/fesm2022/nx-ddd-logging-format.mjs +59 -0
  10. package/fesm2022/nx-ddd-logging-format.mjs.map +1 -0
  11. package/fesm2022/nx-ddd-logging-http.mjs +109 -0
  12. package/fesm2022/nx-ddd-logging-http.mjs.map +1 -0
  13. package/fesm2022/nx-ddd-logging-tee.mjs +1 -22
  14. package/fesm2022/nx-ddd-logging-tee.mjs.map +1 -1
  15. package/fesm2022/nx-ddd-logging.mjs +18 -65
  16. package/fesm2022/nx-ddd-logging.mjs.map +1 -1
  17. package/package.json +13 -1
  18. package/types/nx-ddd-logging-base.d.ts +1 -92
  19. package/types/nx-ddd-logging-base.d.ts.map +1 -1
  20. package/types/nx-ddd-logging-console.d.ts +7 -8
  21. package/types/nx-ddd-logging-console.d.ts.map +1 -1
  22. package/types/nx-ddd-logging-factory.d.ts +15 -0
  23. package/types/nx-ddd-logging-factory.d.ts.map +1 -0
  24. package/types/nx-ddd-logging-file.d.ts +5 -12
  25. package/types/nx-ddd-logging-file.d.ts.map +1 -1
  26. package/types/nx-ddd-logging-format.d.ts +23 -0
  27. package/types/nx-ddd-logging-format.d.ts.map +1 -0
  28. package/types/nx-ddd-logging-http.d.ts +51 -0
  29. package/types/nx-ddd-logging-http.d.ts.map +1 -0
  30. package/types/nx-ddd-logging-tee.d.ts +0 -17
  31. package/types/nx-ddd-logging-tee.d.ts.map +1 -1
  32. package/types/nx-ddd-logging.d.ts +8 -95
  33. package/types/nx-ddd-logging.d.ts.map +1 -1
@@ -0,0 +1,51 @@
1
+ import { Provider } from '@angular/core';
2
+ import { LogLevel, BaseLogger, LogContext } from '@nx-ddd/logging/base';
3
+
4
+ interface HttpLogRecord {
5
+ id: string;
6
+ timestamp: number;
7
+ peer_id: string;
8
+ process_id: number;
9
+ level: string;
10
+ component: string;
11
+ message: string;
12
+ context: string | null;
13
+ error: string | null;
14
+ }
15
+ interface HttpLoggerOptions {
16
+ resolveEndpoint: () => string | null;
17
+ peerId?: string | (() => string);
18
+ minLevel?: LogLevel;
19
+ flushIntervalMs?: number;
20
+ maxBatch?: number;
21
+ maxBuffer?: number;
22
+ fetchFn?: typeof fetch;
23
+ }
24
+ declare const DEFAULT_HTTP_FLUSH_INTERVAL_MS = 1000;
25
+ declare const DEFAULT_HTTP_MAX_BATCH = 200;
26
+ declare const DEFAULT_HTTP_MAX_BUFFER = 5000;
27
+ declare class HttpLogger extends BaseLogger {
28
+ private readonly resolveEndpoint;
29
+ private readonly peerId;
30
+ private readonly minLevel;
31
+ private readonly maxBatch;
32
+ private readonly maxBuffer;
33
+ private readonly fetchFn;
34
+ private readonly buffer;
35
+ private timer;
36
+ private inflight;
37
+ private closed;
38
+ private seq;
39
+ private warnedOnce;
40
+ constructor(options: HttpLoggerOptions);
41
+ log(level: LogLevel, message: string, context?: LogContext, error?: Error): void;
42
+ close(): void;
43
+ private toRecord;
44
+ private flush;
45
+ private safeResolveEndpoint;
46
+ }
47
+ declare function provideHttpLogger(options: HttpLoggerOptions): Provider;
48
+
49
+ export { DEFAULT_HTTP_FLUSH_INTERVAL_MS, DEFAULT_HTTP_MAX_BATCH, DEFAULT_HTTP_MAX_BUFFER, HttpLogger, provideHttpLogger };
50
+ export type { HttpLogRecord, HttpLoggerOptions };
51
+ //# sourceMappingURL=nx-ddd-logging-http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nx-ddd-logging-http.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/http/http.logger.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AAWE;AACA;AACD;;AAGC;;;;;;AAMA;AACD;AAED;AACA;AACA;AAEA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;AAOY;AAYZ;AAMA;AASA;;AAwCA;AAOD;AAED;;;"}
@@ -3,16 +3,6 @@ import * as i0 from '@angular/core';
3
3
  import { Provider } from '@angular/core';
4
4
  import * as fs from 'fs';
5
5
 
6
- /**
7
- * TeeLogger - ファイルとコンソール両方にログを出力(BaseLogger継承版)
8
- *
9
- * BaseLoggerを継承することでLoggingServiceのmulti-providerチェーンに統合可能。
10
- * console.logのオーバーライドを廃止し、正規のLoggingService経由でログレベルを保持する。
11
- *
12
- * - initialize() なし: コンソールのみ出力(ConsoleLogger と同等)
13
- * - initialize(logFile): コンソール + ファイル出力
14
- * - E2E 時は FileLogger を使用するため、TeeLogger は常にコンソール出力が有効
15
- */
16
6
  declare class TeeLogger extends BaseLogger {
17
7
  private logStream;
18
8
  private enableConsoleOutput;
@@ -30,13 +20,6 @@ declare class TeeLogger extends BaseLogger {
30
20
  declare function provideTeeLogger(): Provider[];
31
21
 
32
22
  type RestoreStdioFn = () => void;
33
- /**
34
- * `process.stdout` / `process.stderr` の write を wrap し、書き込み内容を
35
- * `stream` にも tee する。foreground 起動時に `console.log` 直書きを含む
36
- * 全 stdout/stderr 出力をログファイルへ流すために使う。
37
- *
38
- * 戻り値の `restore()` で元の write 関数に戻せる。
39
- */
40
23
  declare function pipeStdioToStream(stream: fs.WriteStream): RestoreStdioFn;
41
24
 
42
25
  export { TeeLogger, pipeStdioToStream, provideTeeLogger };
@@ -1 +1 @@
1
- {"version":3,"file":"nx-ddd-logging-tee.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/tee/tee.logger.ts","../../../../../packages/@nx-ddd/logging/src/lib/tee/pipe-stdio.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;;AAKA;;;;;;;;;AASG;AACH;;;;;;;;AAUsD;;AA6BpD;;;AAUD;AAED;;AChEM;AAIN;;;;;;AAMG;AACH;;;"}
1
+ {"version":3,"file":"nx-ddd-logging-tee.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/tee/tee.logger.ts","../../../../../packages/@nx-ddd/logging/src/lib/tee/pipe-stdio.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;;;AAOA;;;;;;;;AAUsD;;AA6BpD;;;AAUD;AAED;;ACxDM;AAKN;;;"}
@@ -2,11 +2,6 @@ import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Provider, EnvironmentProviders } from '@angular/core';
3
3
  import { ILoggingService as ILoggingService$1, LogLevel as LogLevel$1, LogContext as LogContext$1 } from '@nx-ddd/logging/base';
4
4
 
5
- /**
6
- * LoggingService interfaces
7
- *
8
- * Provides structured logging with different log levels and file output
9
- */
10
5
  declare enum LogLevel {
11
6
  DEBUG = 0,
12
7
  INFO = 1,
@@ -16,58 +11,25 @@ declare enum LogLevel {
16
11
  }
17
12
  interface LogContext {
18
13
  component?: string;
14
+ package?: string;
19
15
  sessionId?: string;
20
16
  clientId?: string;
21
17
  [key: string]: any;
22
18
  }
23
19
  interface ILoggingService {
24
- /**
25
- * Log debug message (for development/troubleshooting)
26
- */
27
20
  debug(message: string, context?: LogContext): void;
28
- /**
29
- * Log informational message
30
- */
31
21
  info(message: string, context?: LogContext): void;
32
- /**
33
- * Log warning message
34
- */
35
22
  warn(message: string, context?: LogContext): void;
36
- /**
37
- * Log error message
38
- */
39
23
  error(message: string, error?: Error, context?: LogContext): void;
40
- /**
41
- * Log fatal error message (application cannot continue)
42
- */
43
24
  fatal(message: string, error?: Error, context?: LogContext): void;
44
- /**
45
- * Set log level filter
46
- */
47
25
  setLogLevel(level: LogLevel): void;
48
- /**
49
- * Set component name for this logger
50
- */
51
26
  setComponent(component: string): void;
52
- /**
53
- * Close logger and flush buffers
54
- */
55
27
  close(): void;
56
28
  }
57
29
 
58
- /**
59
- * Base Logger class for multi-provider logging system
60
- */
61
-
62
30
  declare const LOGGER: InjectionToken<BaseLogger>;
63
31
  declare abstract class BaseLogger {
64
- /**
65
- * Main log method that all loggers must implement
66
- */
67
32
  abstract log(level: LogLevel, message: string, context?: LogContext, error?: Error): void;
68
- /**
69
- * Close logger and flush buffers
70
- */
71
33
  abstract close(): void;
72
34
  debug(message: string, context?: LogContext): void;
73
35
  info(message: string, context?: LogContext): void;
@@ -79,68 +41,15 @@ declare abstract class BaseLogger {
79
41
  }
80
42
  declare function provideLogger(useFactory: () => BaseLogger): Provider;
81
43
 
82
- /**
83
- * LogFilter - Simple function-based log filtering
84
- */
85
-
86
- /**
87
- * Log filter function type
88
- * @param level - The log level
89
- * @param context - Optional log context (component name, etc.)
90
- * @returns true if the log should be output, false to suppress
91
- */
92
44
  type LogFilterFn = (level: LogLevel, context?: LogContext) => boolean;
93
45
  declare const LOG_FILTER: InjectionToken<LogFilterFn>;
94
46
 
95
- /**
96
- * Provider functions for log filtering
97
- */
98
-
99
- /**
100
- * Provide a log filter function
101
- *
102
- * @example
103
- * // Filter by log level
104
- * provideLogFilter((level) => level >= LogLevel.WARN)
105
- *
106
- * @example
107
- * // Filter by component
108
- * provideLogFilter((level, context) => context?.component?.startsWith('My'))
109
- *
110
- * @example
111
- * // Allow all logs
112
- * provideLogFilter(() => true)
113
- */
114
47
  declare function provideLogFilter(filter: LogFilterFn): Provider;
115
- /**
116
- * Configuration for log filtering
117
- */
118
48
  interface LogFilterConfig {
119
49
  minLevel?: LogLevel;
120
50
  componentPattern?: string;
121
51
  }
122
- /**
123
- * Provide a log filter with explicit configuration
124
- * @param config - Filter configuration (minLevel defaults to WARN)
125
- */
126
52
  declare function provideLogFilterWithConfig(config?: LogFilterConfig): Provider;
127
- /**
128
- * @deprecated Use provideLogFilterWithConfig() instead.
129
- * This function directly accesses process.env which violates the rule
130
- * that packages should not access environment variables directly.
131
- *
132
- * Migration example:
133
- * ```typescript
134
- * // Before (in packages)
135
- * provideLogFilterFromEnv()
136
- *
137
- * // After (in application layer)
138
- * provideLogFilterWithConfig({
139
- * minLevel: process.env['LOG_LEVEL'] ? LogLevel[process.env['LOG_LEVEL'].toUpperCase()] : undefined,
140
- * componentPattern: process.env['LOG_COMPONENTS']
141
- * })
142
- * ```
143
- */
144
53
  declare function provideLogFilterFromEnv(): Provider;
145
54
 
146
55
  declare const LOGGING_SERVICE: InjectionToken<ILoggingService$1>;
@@ -150,11 +59,15 @@ interface Logger {
150
59
  info: (...args: Parameters<typeof console['info']>) => void;
151
60
  warn: (...args: Parameters<typeof console['warn']>) => void;
152
61
  error: (...args: Parameters<typeof console['error']>) => void;
62
+ child: (segment: string) => Logger;
63
+ }
64
+ interface LoggerMeta {
65
+ package?: string;
153
66
  }
154
67
  declare class LoggingService implements ILoggingService$1 {
155
68
  private loggers;
156
69
  private filter;
157
- getLogger(name: string): Logger;
70
+ getLogger(name: string, meta?: LoggerMeta): Logger;
158
71
  log(level: LogLevel$1, message: string, context?: LogContext$1, error?: Error): void;
159
72
  close(): void;
160
73
  debug(message: string, context?: LogContext$1): void;
@@ -173,9 +86,9 @@ declare let globalLogging: LoggingService | null;
173
86
  declare function setGlobalLogging(logging: LoggingService): void;
174
87
  declare function getGlobalLogging(): LoggingService | null;
175
88
  declare function createLogger(name: any): ILoggingService$1 | null;
176
- declare function getLogger(name: string): Logger;
89
+ declare function getLogger(name: string, meta?: LoggerMeta): Logger;
177
90
  declare function provideGlobalLogging(): EnvironmentProviders;
178
91
 
179
92
  export { BaseLogger, LOGGER, LOGGING_SERVICE, LOG_FILTER, LogLevel, LoggingService, createLogger, getGlobalLogging, getLogger, globalLogging as logging, provideGlobalLogging, provideLogFilter, provideLogFilterFromEnv, provideLogFilterWithConfig, provideLogger, setGlobalLogging };
180
- export type { ILoggingService, LogContext, LogFilterConfig, LogFilterFn, Logger };
93
+ export type { ILoggingService, LogContext, LogFilterConfig, LogFilterFn, Logger, LoggerMeta };
181
94
  //# sourceMappingURL=nx-ddd-logging.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nx-ddd-logging.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/base/interfaces.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/base.logger.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/log-filter.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/providers.ts","../../../../../packages/@nx-ddd/logging/src/lib/logging.service.ts","../../../../../packages/@nx-ddd/logging/src/lib/global-logging.ts"],"sourcesContent":[null,null,null,null,null,null],"names":[],"mappings":";;;;AAAA;;;;AAIG;AAEH;AACE;AACA;AACA;AACA;AACA;AACD;;;;;AAMC;AACD;;AAGC;;AAEG;;AAGH;;AAEG;;AAGH;;AAEG;;AAGH;;AAEG;AACH;AAEA;;AAEG;AACH;AAEA;;AAEG;AACH;AAEA;;AAEG;AACH;AAEA;;AAEG;;AAEJ;;AC7DD;;AAEG;;AAKH;AAEA;AAEE;;AAEG;;AAQH;;AAEG;;;;;AAgBH;AAIA;;;AAGD;AAED;;AChDA;;AAEG;;AAKH;;;;;AAKG;AACG;AAEN;;ACfA;;AAEG;;AAMH;;;;;;;;;;;;;;AAcG;AACH;AAIA;;AAEG;;;;AAIF;AAED;;;AAGG;AACH;AAaA;;;;;;;;;;;;;;;;AAgBG;AACH;;AClEA;;AAGE;AACA;AACA;AACA;AACA;AACD;AAED;;;AAKE;AAsBA;AAOA;;;;AAgBA;AAIA;AAIA;AAIA;;;AAGD;;AC1ED;;AAGA;AAIA;AAIA;AAQA;AAIA;;;"}
1
+ {"version":3,"file":"nx-ddd-logging.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/base/interfaces.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/base.logger.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/log-filter.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/providers.ts","../../../../../packages/@nx-ddd/logging/src/lib/logging.service.ts","../../../../../packages/@nx-ddd/logging/src/lib/global-logging.ts"],"sourcesContent":[null,null,null,null,null,null],"names":[],"mappings":";;;;AAEA;AACE;AACA;AACA;AACA;AACA;AACD;;;;;;AAOC;AACD;;;;;AAaC;AAGA;AAGA;AAGA;;AAID;;ACrCD;AAEA;;;;;;AA0BE;AAIA;;;AAGD;AAED;;ACpCM;AAEN;;ACDA;;;;AAQC;AAGD;AAcA;;AC7BA;;AAGE;AACA;AACA;AACA;AACA;AACA;AACD;;;AAIA;AAED;;;;AA6BE;AAOA;;;;AAgBA;AAIA;AAIA;AAIA;;;AAGD;;ACjFD;;AAGA;AAIA;AAIA;AAWA;AAIA;;;"}