@nx-ddd/logging 19.50.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.
- package/fesm2022/nx-ddd-logging-base.mjs +0 -51
- package/fesm2022/nx-ddd-logging-base.mjs.map +1 -1
- package/fesm2022/nx-ddd-logging-console.mjs +35 -13
- package/fesm2022/nx-ddd-logging-console.mjs.map +1 -1
- package/fesm2022/nx-ddd-logging-factory.mjs +31 -0
- package/fesm2022/nx-ddd-logging-factory.mjs.map +1 -0
- package/fesm2022/nx-ddd-logging-file.mjs +20 -25
- package/fesm2022/nx-ddd-logging-file.mjs.map +1 -1
- package/fesm2022/nx-ddd-logging-format.mjs +59 -0
- package/fesm2022/nx-ddd-logging-format.mjs.map +1 -0
- package/fesm2022/nx-ddd-logging-http.mjs +109 -0
- package/fesm2022/nx-ddd-logging-http.mjs.map +1 -0
- package/fesm2022/nx-ddd-logging-tee.mjs +1 -22
- package/fesm2022/nx-ddd-logging-tee.mjs.map +1 -1
- package/fesm2022/nx-ddd-logging.mjs +18 -65
- package/fesm2022/nx-ddd-logging.mjs.map +1 -1
- package/package.json +13 -1
- package/types/nx-ddd-logging-base.d.ts +1 -92
- package/types/nx-ddd-logging-base.d.ts.map +1 -1
- package/types/nx-ddd-logging-console.d.ts +7 -8
- package/types/nx-ddd-logging-console.d.ts.map +1 -1
- package/types/nx-ddd-logging-factory.d.ts +15 -0
- package/types/nx-ddd-logging-factory.d.ts.map +1 -0
- package/types/nx-ddd-logging-file.d.ts +5 -12
- package/types/nx-ddd-logging-file.d.ts.map +1 -1
- package/types/nx-ddd-logging-format.d.ts +23 -0
- package/types/nx-ddd-logging-format.d.ts.map +1 -0
- package/types/nx-ddd-logging-http.d.ts +51 -0
- package/types/nx-ddd-logging-http.d.ts.map +1 -0
- package/types/nx-ddd-logging-tee.d.ts +0 -17
- package/types/nx-ddd-logging-tee.d.ts.map +1 -1
- package/types/nx-ddd-logging.d.ts +8 -95
- package/types/nx-ddd-logging.d.ts.map +1 -1
|
@@ -3,16 +3,7 @@ import { BaseLogger, LogLevel, LOGGER } from '@nx-ddd/logging/base';
|
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { Injectable } from '@angular/core';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* `process.stdout` / `process.stderr` の write を wrap し、書き込み内容を
|
|
8
|
-
* `stream` にも tee する。foreground 起動時に `console.log` 直書きを含む
|
|
9
|
-
* 全 stdout/stderr 出力をログファイルへ流すために使う。
|
|
10
|
-
*
|
|
11
|
-
* 戻り値の `restore()` で元の write 関数に戻せる。
|
|
12
|
-
*/
|
|
13
6
|
function pipeStdioToStream(stream) {
|
|
14
|
-
// bind すると同一性比較 (process.stdout.write === origStdoutWrite) が壊れるので、
|
|
15
|
-
// 元の参照をそのまま保持し、wrap 内で apply(thisArg, args) で this を補う
|
|
16
7
|
const origStdoutWrite = process.stdout.write;
|
|
17
8
|
const origStderrWrite = process.stderr.write;
|
|
18
9
|
const wrap = (orig, thisArg) => ((...args) => {
|
|
@@ -20,7 +11,7 @@ function pipeStdioToStream(stream) {
|
|
|
20
11
|
stream.write(args[0]);
|
|
21
12
|
}
|
|
22
13
|
catch {
|
|
23
|
-
|
|
14
|
+
void 0;
|
|
24
15
|
}
|
|
25
16
|
return orig.apply(thisArg, args);
|
|
26
17
|
});
|
|
@@ -32,16 +23,6 @@ function pipeStdioToStream(stream) {
|
|
|
32
23
|
};
|
|
33
24
|
}
|
|
34
25
|
|
|
35
|
-
/**
|
|
36
|
-
* TeeLogger - ファイルとコンソール両方にログを出力(BaseLogger継承版)
|
|
37
|
-
*
|
|
38
|
-
* BaseLoggerを継承することでLoggingServiceのmulti-providerチェーンに統合可能。
|
|
39
|
-
* console.logのオーバーライドを廃止し、正規のLoggingService経由でログレベルを保持する。
|
|
40
|
-
*
|
|
41
|
-
* - initialize() なし: コンソールのみ出力(ConsoleLogger と同等)
|
|
42
|
-
* - initialize(logFile): コンソール + ファイル出力
|
|
43
|
-
* - E2E 時は FileLogger を使用するため、TeeLogger は常にコンソール出力が有効
|
|
44
|
-
*/
|
|
45
26
|
class TeeLogger extends BaseLogger {
|
|
46
27
|
logStream = null;
|
|
47
28
|
enableConsoleOutput = true;
|
|
@@ -64,8 +45,6 @@ class TeeLogger extends BaseLogger {
|
|
|
64
45
|
: console.log;
|
|
65
46
|
method(`[${time}][${levelStr}] ${message}`);
|
|
66
47
|
}
|
|
67
|
-
// pipeStdio mode は console.* → stdio pipe 経由でファイル書き込みされるため、
|
|
68
|
-
// logStream への直接 JSON write は省略して 2 重書き込みを回避する
|
|
69
48
|
if (this.logStream && !this.pipeStdioActive) {
|
|
70
49
|
const ts = new Date().toISOString();
|
|
71
50
|
this.logStream.write(JSON.stringify({ ts, lvl: levelStr, msg: message }) + '\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nx-ddd-logging-tee.mjs","sources":["../../../../../packages/@nx-ddd/logging/src/lib/tee/pipe-stdio.ts","../../../../../packages/@nx-ddd/logging/src/lib/tee/tee.logger.ts","../../../../../packages/@nx-ddd/logging/src/lib/tee/nx-ddd-logging-tee.ts"],"sourcesContent":["import type * as fs from 'fs';\n\nexport type RestoreStdioFn = () => void;\n\ntype WriteFn = typeof process.stdout.write;\n\n
|
|
1
|
+
{"version":3,"file":"nx-ddd-logging-tee.mjs","sources":["../../../../../packages/@nx-ddd/logging/src/lib/tee/pipe-stdio.ts","../../../../../packages/@nx-ddd/logging/src/lib/tee/tee.logger.ts","../../../../../packages/@nx-ddd/logging/src/lib/tee/nx-ddd-logging-tee.ts"],"sourcesContent":["import type * as fs from 'fs';\n\nexport type RestoreStdioFn = () => void;\n\ntype WriteFn = typeof process.stdout.write;\n\n\nexport function pipeStdioToStream(stream: fs.WriteStream): RestoreStdioFn {\n \n \n const origStdoutWrite = process.stdout.write as WriteFn;\n const origStderrWrite = process.stderr.write as WriteFn;\n\n const wrap = (orig: WriteFn, thisArg: NodeJS.WriteStream): WriteFn =>\n ((...args: unknown[]) => {\n try {\n stream.write(args[0] as Parameters<typeof stream.write>[0]);\n } catch {\n void 0;\n }\n return (orig as (...a: unknown[]) => boolean).apply(thisArg, args);\n }) as WriteFn;\n\n process.stdout.write = wrap(origStdoutWrite, process.stdout);\n process.stderr.write = wrap(origStderrWrite, process.stderr);\n\n return () => {\n process.stdout.write = origStdoutWrite;\n process.stderr.write = origStderrWrite;\n };\n}\n","import * as fs from 'fs';\nimport type { WriteStream } from 'fs';\nimport { BaseLogger, LOGGER, LogLevel } from '@nx-ddd/logging/base';\nimport { Injectable, Provider } from '@angular/core';\nimport { pipeStdioToStream, RestoreStdioFn } from './pipe-stdio';\n\n\n@Injectable()\nexport class TeeLogger extends BaseLogger {\n private logStream: WriteStream | null = null;\n private enableConsoleOutput = true;\n private restoreStdio: RestoreStdioFn | null = null;\n private pipeStdioActive = false;\n\n initialize(\n logFilePath: string,\n forceConsole = false,\n options?: { isE2e?: boolean; pipeStdio?: boolean },\n ): void {\n this.logStream = fs.createWriteStream(logFilePath, { flags: 'a' });\n this.enableConsoleOutput = forceConsole || !options?.isE2e;\n this.pipeStdioActive = options?.pipeStdio === true;\n if (this.pipeStdioActive) {\n this.restoreStdio = pipeStdioToStream(this.logStream);\n }\n }\n\n log(level: LogLevel, message: string): void {\n const levelStr = LogLevel[level] ?? 'LOG';\n\n if (this.enableConsoleOutput) {\n const time = new Date().toTimeString().slice(0, 8);\n const method = level >= LogLevel.ERROR ? console.error\n : level >= LogLevel.WARN ? console.warn\n : console.log;\n method(`[${time}][${levelStr}] ${message}`);\n }\n\n \n \n if (this.logStream && !this.pipeStdioActive) {\n const ts = new Date().toISOString();\n this.logStream.write(JSON.stringify({ ts, lvl: levelStr, msg: message }) + '\\n');\n }\n }\n\n close(): void {\n if (this.restoreStdio) {\n this.restoreStdio();\n this.restoreStdio = null;\n }\n if (this.logStream) {\n this.logStream.end();\n this.logStream = null;\n }\n }\n}\n\nexport function provideTeeLogger(): Provider[] {\n return [\n { provide: TeeLogger, useClass: TeeLogger },\n { provide: LOGGER, multi: true, useExisting: TeeLogger },\n ];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAOM,SAAU,iBAAiB,CAAC,MAAsB,EAAA;AAGtD,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,KAAgB;AACvD,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,KAAgB;AAEvD,IAAA,MAAM,IAAI,GAAG,CAAC,IAAa,EAAE,OAA2B,MACrD,CAAC,GAAG,IAAe,KAAI;AACtB,QAAA,IAAI;YACF,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAuC,CAAC;QAC7D;AAAE,QAAA,MAAM;AACN,YAAA,KAAK,CAAC;QACR;QACA,OAAQ,IAAqC,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;AACpE,IAAA,CAAC,CAAY;AAEf,IAAA,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC;AAC5D,IAAA,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC;AAE5D,IAAA,OAAO,MAAK;AACV,QAAA,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,eAAe;AACtC,QAAA,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,eAAe;AACxC,IAAA,CAAC;AACH;;ACtBM,MAAO,SAAU,SAAQ,UAAU,CAAA;IAC/B,SAAS,GAAuB,IAAI;IACpC,mBAAmB,GAAG,IAAI;IAC1B,YAAY,GAA0B,IAAI;IAC1C,eAAe,GAAG,KAAK;AAE/B,IAAA,UAAU,CACR,WAAmB,EACnB,YAAY,GAAG,KAAK,EACpB,OAAkD,EAAA;AAElD,QAAA,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC,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AACnB,YAAA,IAAI,CAAC,YAAY,GAAG,IAAI;QAC1B;AACA,QAAA,IAAI,IAAI,CAAC,SAAS,EAAE;AAClB,YAAA,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;AACpB,YAAA,IAAI,CAAC,SAAS,GAAG,IAAI;QACvB;IACF;uGA/CW,SAAS,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;2GAAT,SAAS,EAAA,CAAA;;2FAAT,SAAS,EAAA,UAAA,EAAA,CAAA;kBADrB;;SAmDe,gBAAgB,GAAA;IAC9B,OAAO;AACL,QAAA,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE;QAC3C,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE;KACzD;AACH;;AC/DA;;AAEG;;;;"}
|
|
@@ -2,11 +2,6 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { InjectionToken, Injectable, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';
|
|
3
3
|
import { LOGGER as LOGGER$1, LOG_FILTER as LOG_FILTER$1, LogLevel as LogLevel$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
|
var LogLevel;
|
|
11
6
|
(function (LogLevel) {
|
|
12
7
|
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
@@ -16,12 +11,8 @@ var LogLevel;
|
|
|
16
11
|
LogLevel[LogLevel["FATAL"] = 4] = "FATAL";
|
|
17
12
|
})(LogLevel || (LogLevel = {}));
|
|
18
13
|
|
|
19
|
-
/**
|
|
20
|
-
* Base Logger class for multi-provider logging system
|
|
21
|
-
*/
|
|
22
14
|
const LOGGER = new InjectionToken('Logger');
|
|
23
15
|
class BaseLogger {
|
|
24
|
-
// Convenience methods
|
|
25
16
|
debug(message, context) {
|
|
26
17
|
this.log(LogLevel.DEBUG, message, context);
|
|
27
18
|
}
|
|
@@ -51,36 +42,11 @@ function provideLogger(useFactory) {
|
|
|
51
42
|
};
|
|
52
43
|
}
|
|
53
44
|
|
|
54
|
-
/**
|
|
55
|
-
* LogFilter - Simple function-based log filtering
|
|
56
|
-
*/
|
|
57
45
|
const LOG_FILTER = new InjectionToken('LogFilter');
|
|
58
46
|
|
|
59
|
-
/**
|
|
60
|
-
* Provider functions for log filtering
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* Provide a log filter function
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* // Filter by log level
|
|
67
|
-
* provideLogFilter((level) => level >= LogLevel.WARN)
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* // Filter by component
|
|
71
|
-
* provideLogFilter((level, context) => context?.component?.startsWith('My'))
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* // Allow all logs
|
|
75
|
-
* provideLogFilter(() => true)
|
|
76
|
-
*/
|
|
77
47
|
function provideLogFilter(filter) {
|
|
78
48
|
return { provide: LOG_FILTER, useValue: filter };
|
|
79
49
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Provide a log filter with explicit configuration
|
|
82
|
-
* @param config - Filter configuration (minLevel defaults to WARN)
|
|
83
|
-
*/
|
|
84
50
|
function provideLogFilterWithConfig(config) {
|
|
85
51
|
const minLevel = config?.minLevel ?? LogLevel.WARN;
|
|
86
52
|
const componentRegex = config?.componentPattern ? new RegExp(config.componentPattern) : null;
|
|
@@ -93,23 +59,6 @@ function provideLogFilterWithConfig(config) {
|
|
|
93
59
|
return true;
|
|
94
60
|
});
|
|
95
61
|
}
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated Use provideLogFilterWithConfig() instead.
|
|
98
|
-
* This function directly accesses process.env which violates the rule
|
|
99
|
-
* that packages should not access environment variables directly.
|
|
100
|
-
*
|
|
101
|
-
* Migration example:
|
|
102
|
-
* ```typescript
|
|
103
|
-
* // Before (in packages)
|
|
104
|
-
* provideLogFilterFromEnv()
|
|
105
|
-
*
|
|
106
|
-
* // After (in application layer)
|
|
107
|
-
* provideLogFilterWithConfig({
|
|
108
|
-
* minLevel: process.env['LOG_LEVEL'] ? LogLevel[process.env['LOG_LEVEL'].toUpperCase()] : undefined,
|
|
109
|
-
* componentPattern: process.env['LOG_COMPONENTS']
|
|
110
|
-
* })
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
62
|
function provideLogFilterFromEnv() {
|
|
114
63
|
console.warn('[DEPRECATED] provideLogFilterFromEnv() is deprecated. Use provideLogFilterWithConfig() instead.');
|
|
115
64
|
return provideLogFilterWithConfig();
|
|
@@ -119,7 +68,7 @@ const LOGGING_SERVICE = new InjectionToken('LoggingService');
|
|
|
119
68
|
class LoggingService {
|
|
120
69
|
loggers = inject(LOGGER$1, { optional: true }) ?? [];
|
|
121
70
|
filter = inject(LOG_FILTER$1, { optional: true });
|
|
122
|
-
getLogger(name) {
|
|
71
|
+
getLogger(name, meta) {
|
|
123
72
|
const format = (...args) => {
|
|
124
73
|
return args.map(arg => {
|
|
125
74
|
if (typeof arg === 'string')
|
|
@@ -132,18 +81,19 @@ class LoggingService {
|
|
|
132
81
|
return serialized !== undefined ? serialized : String(arg);
|
|
133
82
|
}).join(' ');
|
|
134
83
|
};
|
|
84
|
+
const context = { component: name };
|
|
85
|
+
if (meta?.package != null)
|
|
86
|
+
context['package'] = meta.package;
|
|
135
87
|
return {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
error: (...args) => this.log(LogLevel$1.ERROR, format(`[${name}]`, ...args)),
|
|
88
|
+
log: (...args) => this.log(LogLevel$1.INFO, format(...args), context),
|
|
89
|
+
debug: (...args) => this.log(LogLevel$1.DEBUG, format(...args), context),
|
|
90
|
+
info: (...args) => this.log(LogLevel$1.INFO, format(...args), context),
|
|
91
|
+
warn: (...args) => this.log(LogLevel$1.WARN, format(...args), context),
|
|
92
|
+
error: (...args) => this.log(LogLevel$1.ERROR, format(...args), context),
|
|
93
|
+
child: (segment) => this.getLogger(`${name}.${segment}`, meta),
|
|
143
94
|
};
|
|
144
95
|
}
|
|
145
96
|
log(level, message, context, error) {
|
|
146
|
-
// Apply filtering at service level if LogFilter is provided
|
|
147
97
|
if (this.filter && !this.filter(level, context))
|
|
148
98
|
return;
|
|
149
99
|
this.loggers.forEach(logger => logger.log(level, message, context, error));
|
|
@@ -167,10 +117,10 @@ class LoggingService {
|
|
|
167
117
|
this.log(LogLevel$1.FATAL, message, context, error);
|
|
168
118
|
}
|
|
169
119
|
setLogLevel(_level) {
|
|
170
|
-
|
|
120
|
+
void 0;
|
|
171
121
|
}
|
|
172
122
|
setComponent(_component) {
|
|
173
|
-
|
|
123
|
+
void 0;
|
|
174
124
|
}
|
|
175
125
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: LoggingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
176
126
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: LoggingService, providedIn: 'root' });
|
|
@@ -192,9 +142,12 @@ function createLogger(name) {
|
|
|
192
142
|
}
|
|
193
143
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
194
144
|
const noop = () => { };
|
|
195
|
-
const noopLogger = {
|
|
196
|
-
|
|
197
|
-
|
|
145
|
+
const noopLogger = {
|
|
146
|
+
log: noop, debug: noop, info: noop, warn: noop, error: noop,
|
|
147
|
+
child: () => noopLogger,
|
|
148
|
+
};
|
|
149
|
+
function getLogger(name, meta) {
|
|
150
|
+
return globalLogging?.getLogger(name, meta) ?? noopLogger;
|
|
198
151
|
}
|
|
199
152
|
function provideGlobalLogging() {
|
|
200
153
|
return makeEnvironmentProviders([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nx-ddd-logging.mjs","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","../../../../../packages/@nx-ddd/logging/src/lib/nx-ddd-logging.ts"],"sourcesContent":["/**\n * LoggingService interfaces\n *\n * Provides structured logging with different log levels and file output\n */\n\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n FATAL = 4,\n}\n\nexport interface LogContext {\n component?: string;\n sessionId?: string;\n clientId?: string;\n [key: string]: any;\n}\n\nexport interface ILoggingService {\n /**\n * Log debug message (for development/troubleshooting)\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log informational message\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log warning message\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log error message\n */\n error(message: string, error?: Error, context?: LogContext): void;\n\n /**\n * Log fatal error message (application cannot continue)\n */\n fatal(message: string, error?: Error, context?: LogContext): void;\n\n /**\n * Set log level filter\n */\n setLogLevel(level: LogLevel): void;\n\n /**\n * Set component name for this logger\n */\n setComponent(component: string): void;\n\n /**\n * Close logger and flush buffers\n */\n close(): void;\n}\n","/**\n * Base Logger class for multi-provider logging system\n */\n\nimport { Injectable, InjectionToken, Provider } from '@angular/core';\nimport { LogLevel, LogContext } from './interfaces';\n\nexport const LOGGER = new InjectionToken<BaseLogger>('Logger');\n\n@Injectable()\nexport abstract class BaseLogger {\n /**\n * Main log method that all loggers must implement\n */\n abstract log(\n level: LogLevel,\n message: string,\n context?: LogContext,\n error?: Error\n ): void;\n\n /**\n * Close logger and flush buffers\n */\n abstract close(): void;\n\n // Convenience methods\n debug(message: string, context?: LogContext): void {\n this.log(LogLevel.DEBUG, message, context);\n }\n\n info(message: string, context?: LogContext): void {\n this.log(LogLevel.INFO, message, context);\n }\n\n warn(message: string, context?: LogContext): void {\n this.log(LogLevel.WARN, message, context);\n }\n\n error(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.ERROR, message, context, error);\n }\n\n fatal(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.FATAL, message, context, error);\n }\n}\n\nexport function provideLogger(useFactory: () => BaseLogger): Provider {\n return {\n provide: LOGGER,\n multi: true,\n useFactory,\n };\n}\n","/**\n * LogFilter - Simple function-based log filtering\n */\n\nimport { InjectionToken } from '@angular/core';\nimport { LogLevel, LogContext } from './interfaces';\n\n/**\n * Log filter function type\n * @param level - The log level\n * @param context - Optional log context (component name, etc.)\n * @returns true if the log should be output, false to suppress\n */\nexport type LogFilterFn = (level: LogLevel, context?: LogContext) => boolean;\n\nexport const LOG_FILTER = new InjectionToken<LogFilterFn>('LogFilter');\n","/**\n * Provider functions for log filtering\n */\n\nimport { Provider } from '@angular/core';\nimport { LogLevel } from './interfaces';\nimport { LOG_FILTER, LogFilterFn } from './log-filter';\n\n/**\n * Provide a log filter function\n *\n * @example\n * // Filter by log level\n * provideLogFilter((level) => level >= LogLevel.WARN)\n *\n * @example\n * // Filter by component\n * provideLogFilter((level, context) => context?.component?.startsWith('My'))\n *\n * @example\n * // Allow all logs\n * provideLogFilter(() => true)\n */\nexport function provideLogFilter(filter: LogFilterFn): Provider {\n return { provide: LOG_FILTER, useValue: filter };\n}\n\n/**\n * Configuration for log filtering\n */\nexport interface LogFilterConfig {\n minLevel?: LogLevel;\n componentPattern?: string;\n}\n\n/**\n * Provide a log filter with explicit configuration\n * @param config - Filter configuration (minLevel defaults to WARN)\n */\nexport function provideLogFilterWithConfig(config?: LogFilterConfig): Provider {\n const minLevel = config?.minLevel ?? LogLevel.WARN;\n const componentRegex = config?.componentPattern ? new RegExp(config.componentPattern) : null;\n\n return provideLogFilter((level, context) => {\n if (level < minLevel) return false;\n if (componentRegex && context?.component && !componentRegex.test(context.component)) {\n return false;\n }\n return true;\n });\n}\n\n/**\n * @deprecated Use provideLogFilterWithConfig() instead.\n * This function directly accesses process.env which violates the rule\n * that packages should not access environment variables directly.\n *\n * Migration example:\n * ```typescript\n * // Before (in packages)\n * provideLogFilterFromEnv()\n *\n * // After (in application layer)\n * provideLogFilterWithConfig({\n * minLevel: process.env['LOG_LEVEL'] ? LogLevel[process.env['LOG_LEVEL'].toUpperCase()] : undefined,\n * componentPattern: process.env['LOG_COMPONENTS']\n * })\n * ```\n */\nexport function provideLogFilterFromEnv(): Provider {\n console.warn('[DEPRECATED] provideLogFilterFromEnv() is deprecated. Use provideLogFilterWithConfig() instead.');\n return provideLogFilterWithConfig();\n}\n","import { inject, Injectable, InjectionToken } from \"@angular/core\";\nimport { BaseLogger, ILoggingService, LogContext, LOGGER, LogLevel, LOG_FILTER, LogFilterFn } from \"@nx-ddd/logging/base\";\n\nexport const LOGGING_SERVICE = new InjectionToken<ILoggingService>('LoggingService');\n\nexport interface Logger {\n log: (...args: Parameters<typeof console['log']>) => void;\n debug: (...args: Parameters<typeof console['debug']>) => void;\n info: (...args: Parameters<typeof console['info']>) => void;\n warn: (...args: Parameters<typeof console['warn']>) => void;\n error: (...args: Parameters<typeof console['error']>) => void;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class LoggingService implements ILoggingService {\n private loggers = inject<BaseLogger[]>(LOGGER, { optional: true }) ?? [];\n private filter = inject<LogFilterFn>(LOG_FILTER, { optional: true });\n\n getLogger(name: string): Logger {\n const format = (...args: Parameters<typeof console['log']>) => {\n return args.map(arg => {\n if (typeof arg === 'string') return arg;\n if (arg === undefined) return 'undefined';\n if (arg === null) return 'null';\n const serialized = JSON.stringify(arg);\n return serialized !== undefined ? serialized : String(arg);\n }).join(' ');\n };\n\n return {\n // NOTE: log() は `console.log` の慣習に合わせて INFO レベルで出力する。\n // 以前は DEBUG にマップされていたため、INFO フィルタで消える罠があった。\n log: (...args) => this.log(LogLevel.INFO, format(`[${name}]`, ...args)),\n debug: (...args) => this.log(LogLevel.DEBUG, format(`[${name}]`, ...args)),\n info: (...args) => this.log(LogLevel.INFO, format(`[${name}]`, ...args)),\n warn: (...args) => this.log(LogLevel.WARN, format(`[${name}]`, ...args)),\n error: (...args) => this.log(LogLevel.ERROR, format(`[${name}]`, ...args)),\n };\n }\n\n log(level: LogLevel, message: string, context?: LogContext, error?: Error): void {\n // Apply filtering at service level if LogFilter is provided\n if (this.filter && !this.filter(level, context)) return;\n\n this.loggers.forEach(logger => logger.log(level, message, context, error));\n }\n\n close(): void {\n this.loggers.forEach(logger => logger.close());\n }\n\n debug(message: string, context?: LogContext): void {\n this.log(LogLevel.DEBUG, message, context);\n }\n\n info(message: string, context?: LogContext): void {\n this.log(LogLevel.INFO, message, context);\n }\n\n warn(message: string, context?: LogContext): void {\n this.log(LogLevel.WARN, message, context);\n }\n\n error(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.ERROR, message, context, error);\n }\n\n fatal(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.FATAL, message, context, error);\n }\n\n setLogLevel(_level: LogLevel): void {\n // this.loggers.forEach(logger => logger.setLogLevel(level));\n }\n\n setComponent(_component: string): void {\n // this.loggers.forEach(logger => logger.setComponent(component));\n }\n}\n","import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\nimport { ILoggingService } from '@nx-ddd/logging/base';\nimport { Logger, LoggingService } from './logging.service';\n\nlet globalLogging: LoggingService | null = null;\nexport { globalLogging as logging };\n\nexport function setGlobalLogging(logging: LoggingService): void {\n globalLogging = logging;\n}\n\nexport function getGlobalLogging(): LoggingService | null {\n return globalLogging;\n}\n\nexport function createLogger(name: any): ILoggingService | null {\n return globalLogging;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\nconst noopLogger: Logger = { log: noop, debug: noop, info: noop, warn: noop, error: noop };\n\nexport function getLogger(name: string): Logger {\n return globalLogging?.getLogger(name) ?? noopLogger;\n}\n\nexport function provideGlobalLogging(): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideAppInitializer(() => {\n return setGlobalLogging(inject(LoggingService));\n })\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["LOGGER","LOG_FILTER","LogLevel"],"mappings":";;;;AAAA;;;;AAIG;IAES;AAAZ,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACT,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACT,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACX,CAAC,EANW,QAAQ,KAAR,QAAQ,GAAA,EAAA,CAAA,CAAA;;ACNpB;;AAEG;MAKU,MAAM,GAAG,IAAI,cAAc,CAAa,QAAQ;MAGvC,UAAU,CAAA;;IAiB9B,KAAK,CAAC,OAAe,EAAE,OAAoB,EAAA;QACzC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC;IAC5C;IAEA,IAAI,CAAC,OAAe,EAAE,OAAoB,EAAA;QACxC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;IAC3C;IAEA,IAAI,CAAC,OAAe,EAAE,OAAoB,EAAA;QACxC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,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9B,IAAA,OAAO,aAAa;AACtB;AAEM,SAAU,YAAY,CAAC,IAAS,EAAA;AACpC,IAAA,OAAO,aAAa;AACtB;AAEA;AACA,MAAM,IAAI,GAAG,MAAK,EAAE,CAAC;AACrB,MAAM,UAAU,GAAW,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AAEpF,SAAU,SAAS,CAAC,IAAY,EAAA;IACpC,OAAO,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,UAAU;AACrD;SAEgB,oBAAoB,GAAA;AAClC,IAAA,OAAO,wBAAwB,CAAC;QAC9B,qBAAqB,CAAC,MAAK;AACzB,YAAA,OAAO,gBAAgB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AACjD,QAAA,CAAC;AACF,KAAA,CAAC;AACJ;;ACjCA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"nx-ddd-logging.mjs","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","../../../../../packages/@nx-ddd/logging/src/lib/nx-ddd-logging.ts"],"sourcesContent":["\n\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n FATAL = 4,\n}\n\nexport interface LogContext {\n component?: string;\n package?: string;\n sessionId?: string;\n clientId?: string;\n [key: string]: any;\n}\n\nexport interface ILoggingService {\n \n debug(message: string, context?: LogContext): void;\n\n \n info(message: string, context?: LogContext): void;\n\n \n warn(message: string, context?: LogContext): void;\n\n \n error(message: string, error?: Error, context?: LogContext): void;\n\n \n fatal(message: string, error?: Error, context?: LogContext): void;\n\n \n setLogLevel(level: LogLevel): void;\n\n \n setComponent(component: string): void;\n\n \n close(): void;\n}\n","\n\nimport { Injectable, InjectionToken, Provider } from '@angular/core';\nimport { LogLevel, LogContext } from './interfaces';\n\nexport const LOGGER = new InjectionToken<BaseLogger>('Logger');\n\n@Injectable()\nexport abstract class BaseLogger {\n \n abstract log(\n level: LogLevel,\n message: string,\n context?: LogContext,\n error?: Error\n ): void;\n\n \n abstract close(): void;\n\n \n debug(message: string, context?: LogContext): void {\n this.log(LogLevel.DEBUG, message, context);\n }\n\n info(message: string, context?: LogContext): void {\n this.log(LogLevel.INFO, message, context);\n }\n\n warn(message: string, context?: LogContext): void {\n this.log(LogLevel.WARN, message, context);\n }\n\n error(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.ERROR, message, context, error);\n }\n\n fatal(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.FATAL, message, context, error);\n }\n}\n\nexport function provideLogger(useFactory: () => BaseLogger): Provider {\n return {\n provide: LOGGER,\n multi: true,\n useFactory,\n };\n}\n","\n\nimport { InjectionToken } from '@angular/core';\nimport { LogLevel, LogContext } from './interfaces';\n\n\nexport type LogFilterFn = (level: LogLevel, context?: LogContext) => boolean;\n\nexport const LOG_FILTER = new InjectionToken<LogFilterFn>('LogFilter');\n","\n\nimport { Provider } from '@angular/core';\nimport { LogLevel } from './interfaces';\nimport { LOG_FILTER, LogFilterFn } from './log-filter';\n\n\nexport function provideLogFilter(filter: LogFilterFn): Provider {\n return { provide: LOG_FILTER, useValue: filter };\n}\n\n\nexport interface LogFilterConfig {\n minLevel?: LogLevel;\n componentPattern?: string;\n}\n\n\nexport function provideLogFilterWithConfig(config?: LogFilterConfig): Provider {\n const minLevel = config?.minLevel ?? LogLevel.WARN;\n const componentRegex = config?.componentPattern ? new RegExp(config.componentPattern) : null;\n\n return provideLogFilter((level, context) => {\n if (level < minLevel) return false;\n if (componentRegex && context?.component && !componentRegex.test(context.component)) {\n return false;\n }\n return true;\n });\n}\n\n\nexport function provideLogFilterFromEnv(): Provider {\n console.warn('[DEPRECATED] provideLogFilterFromEnv() is deprecated. Use provideLogFilterWithConfig() instead.');\n return provideLogFilterWithConfig();\n}\n","import { inject, Injectable, InjectionToken } from \"@angular/core\";\nimport { BaseLogger, ILoggingService, LogContext, LOGGER, LogLevel, LOG_FILTER, LogFilterFn } from \"@nx-ddd/logging/base\";\n\nexport const LOGGING_SERVICE = new InjectionToken<ILoggingService>('LoggingService');\n\nexport interface Logger {\n log: (...args: Parameters<typeof console['log']>) => void;\n debug: (...args: Parameters<typeof console['debug']>) => void;\n info: (...args: Parameters<typeof console['info']>) => void;\n warn: (...args: Parameters<typeof console['warn']>) => void;\n error: (...args: Parameters<typeof console['error']>) => void;\n child: (segment: string) => Logger;\n}\n\nexport interface LoggerMeta {\n package?: string;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class LoggingService implements ILoggingService {\n private loggers = inject<BaseLogger[]>(LOGGER, { optional: true }) ?? [];\n private filter = inject<LogFilterFn>(LOG_FILTER, { optional: true });\n\n getLogger(name: string, meta?: LoggerMeta): Logger {\n const format = (...args: Parameters<typeof console['log']>) => {\n return args.map(arg => {\n if (typeof arg === 'string') return arg;\n if (arg === undefined) return 'undefined';\n if (arg === null) return 'null';\n const serialized = JSON.stringify(arg);\n return serialized !== undefined ? serialized : String(arg);\n }).join(' ');\n };\n\n const context: LogContext = { component: name };\n if (meta?.package != null) context['package'] = meta.package;\n\n return {\n log: (...args) => this.log(LogLevel.INFO, format(...args), context),\n debug: (...args) => this.log(LogLevel.DEBUG, format(...args), context),\n info: (...args) => this.log(LogLevel.INFO, format(...args), context),\n warn: (...args) => this.log(LogLevel.WARN, format(...args), context),\n error: (...args) => this.log(LogLevel.ERROR, format(...args), context),\n child: (segment: string) => this.getLogger(`${name}.${segment}`, meta),\n };\n }\n\n log(level: LogLevel, message: string, context?: LogContext, error?: Error): void {\n \n if (this.filter && !this.filter(level, context)) return;\n\n this.loggers.forEach(logger => logger.log(level, message, context, error));\n }\n\n close(): void {\n this.loggers.forEach(logger => logger.close());\n }\n\n debug(message: string, context?: LogContext): void {\n this.log(LogLevel.DEBUG, message, context);\n }\n\n info(message: string, context?: LogContext): void {\n this.log(LogLevel.INFO, message, context);\n }\n\n warn(message: string, context?: LogContext): void {\n this.log(LogLevel.WARN, message, context);\n }\n\n error(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.ERROR, message, context, error);\n }\n\n fatal(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.FATAL, message, context, error);\n }\n\n setLogLevel(_level: LogLevel): void {\n void 0;\n }\n\n setComponent(_component: string): void {\n void 0;\n }\n}\n","import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\nimport { ILoggingService } from '@nx-ddd/logging/base';\nimport { Logger, LoggerMeta, LoggingService } from './logging.service';\n\nlet globalLogging: LoggingService | null = null;\nexport { globalLogging as logging };\n\nexport function setGlobalLogging(logging: LoggingService): void {\n globalLogging = logging;\n}\n\nexport function getGlobalLogging(): LoggingService | null {\n return globalLogging;\n}\n\nexport function createLogger(name: any): ILoggingService | null {\n return globalLogging;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\nconst noopLogger: Logger = {\n log: noop, debug: noop, info: noop, warn: noop, error: noop,\n child: () => noopLogger,\n};\n\nexport function getLogger(name: string, meta?: LoggerMeta): Logger {\n return globalLogging?.getLogger(name, meta) ?? noopLogger;\n}\n\nexport function provideGlobalLogging(): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideAppInitializer(() => {\n return setGlobalLogging(inject(LoggingService));\n })\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["LOGGER","LOG_FILTER","LogLevel"],"mappings":";;;;IAEY;AAAZ,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA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I;AAC3D,IAAA,KAAK,EAAE,MAAM,UAAU;CACxB;AAEK,SAAU,SAAS,CAAC,IAAY,EAAE,IAAiB,EAAA;IACvD,OAAO,aAAa,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,UAAU;AAC3D;SAEgB,oBAAoB,GAAA;AAClC,IAAA,OAAO,wBAAwB,CAAC;QAC9B,qBAAqB,CAAC,MAAK;AACzB,YAAA,OAAO,gBAAgB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AACjD,QAAA,CAAC;AACF,KAAA,CAAC;AACJ;;ACpCA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx-ddd/logging",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.80.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@angular/core": "19.1.4"
|
|
@@ -26,10 +26,22 @@
|
|
|
26
26
|
"types": "./types/nx-ddd-logging-console.d.ts",
|
|
27
27
|
"default": "./fesm2022/nx-ddd-logging-console.mjs"
|
|
28
28
|
},
|
|
29
|
+
"./factory": {
|
|
30
|
+
"types": "./types/nx-ddd-logging-factory.d.ts",
|
|
31
|
+
"default": "./fesm2022/nx-ddd-logging-factory.mjs"
|
|
32
|
+
},
|
|
29
33
|
"./file": {
|
|
30
34
|
"types": "./types/nx-ddd-logging-file.d.ts",
|
|
31
35
|
"default": "./fesm2022/nx-ddd-logging-file.mjs"
|
|
32
36
|
},
|
|
37
|
+
"./format": {
|
|
38
|
+
"types": "./types/nx-ddd-logging-format.d.ts",
|
|
39
|
+
"default": "./fesm2022/nx-ddd-logging-format.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./http": {
|
|
42
|
+
"types": "./types/nx-ddd-logging-http.d.ts",
|
|
43
|
+
"default": "./fesm2022/nx-ddd-logging-http.mjs"
|
|
44
|
+
},
|
|
33
45
|
"./tee": {
|
|
34
46
|
"types": "./types/nx-ddd-logging-tee.d.ts",
|
|
35
47
|
"default": "./fesm2022/nx-ddd-logging-tee.mjs"
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Provider } from '@angular/core';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* LoggingService interfaces
|
|
6
|
-
*
|
|
7
|
-
* Provides structured logging with different log levels and file output
|
|
8
|
-
*/
|
|
9
4
|
declare enum LogLevel {
|
|
10
5
|
DEBUG = 0,
|
|
11
6
|
INFO = 1,
|
|
@@ -15,58 +10,25 @@ declare enum LogLevel {
|
|
|
15
10
|
}
|
|
16
11
|
interface LogContext {
|
|
17
12
|
component?: string;
|
|
13
|
+
package?: string;
|
|
18
14
|
sessionId?: string;
|
|
19
15
|
clientId?: string;
|
|
20
16
|
[key: string]: any;
|
|
21
17
|
}
|
|
22
18
|
interface ILoggingService {
|
|
23
|
-
/**
|
|
24
|
-
* Log debug message (for development/troubleshooting)
|
|
25
|
-
*/
|
|
26
19
|
debug(message: string, context?: LogContext): void;
|
|
27
|
-
/**
|
|
28
|
-
* Log informational message
|
|
29
|
-
*/
|
|
30
20
|
info(message: string, context?: LogContext): void;
|
|
31
|
-
/**
|
|
32
|
-
* Log warning message
|
|
33
|
-
*/
|
|
34
21
|
warn(message: string, context?: LogContext): void;
|
|
35
|
-
/**
|
|
36
|
-
* Log error message
|
|
37
|
-
*/
|
|
38
22
|
error(message: string, error?: Error, context?: LogContext): void;
|
|
39
|
-
/**
|
|
40
|
-
* Log fatal error message (application cannot continue)
|
|
41
|
-
*/
|
|
42
23
|
fatal(message: string, error?: Error, context?: LogContext): void;
|
|
43
|
-
/**
|
|
44
|
-
* Set log level filter
|
|
45
|
-
*/
|
|
46
24
|
setLogLevel(level: LogLevel): void;
|
|
47
|
-
/**
|
|
48
|
-
* Set component name for this logger
|
|
49
|
-
*/
|
|
50
25
|
setComponent(component: string): void;
|
|
51
|
-
/**
|
|
52
|
-
* Close logger and flush buffers
|
|
53
|
-
*/
|
|
54
26
|
close(): void;
|
|
55
27
|
}
|
|
56
28
|
|
|
57
|
-
/**
|
|
58
|
-
* Base Logger class for multi-provider logging system
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
29
|
declare const LOGGER: InjectionToken<BaseLogger>;
|
|
62
30
|
declare abstract class BaseLogger {
|
|
63
|
-
/**
|
|
64
|
-
* Main log method that all loggers must implement
|
|
65
|
-
*/
|
|
66
31
|
abstract log(level: LogLevel, message: string, context?: LogContext, error?: Error): void;
|
|
67
|
-
/**
|
|
68
|
-
* Close logger and flush buffers
|
|
69
|
-
*/
|
|
70
32
|
abstract close(): void;
|
|
71
33
|
debug(message: string, context?: LogContext): void;
|
|
72
34
|
info(message: string, context?: LogContext): void;
|
|
@@ -78,68 +40,15 @@ declare abstract class BaseLogger {
|
|
|
78
40
|
}
|
|
79
41
|
declare function provideLogger(useFactory: () => BaseLogger): Provider;
|
|
80
42
|
|
|
81
|
-
/**
|
|
82
|
-
* LogFilter - Simple function-based log filtering
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Log filter function type
|
|
87
|
-
* @param level - The log level
|
|
88
|
-
* @param context - Optional log context (component name, etc.)
|
|
89
|
-
* @returns true if the log should be output, false to suppress
|
|
90
|
-
*/
|
|
91
43
|
type LogFilterFn = (level: LogLevel, context?: LogContext) => boolean;
|
|
92
44
|
declare const LOG_FILTER: InjectionToken<LogFilterFn>;
|
|
93
45
|
|
|
94
|
-
/**
|
|
95
|
-
* Provider functions for log filtering
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Provide a log filter function
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* // Filter by log level
|
|
103
|
-
* provideLogFilter((level) => level >= LogLevel.WARN)
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* // Filter by component
|
|
107
|
-
* provideLogFilter((level, context) => context?.component?.startsWith('My'))
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* // Allow all logs
|
|
111
|
-
* provideLogFilter(() => true)
|
|
112
|
-
*/
|
|
113
46
|
declare function provideLogFilter(filter: LogFilterFn): Provider;
|
|
114
|
-
/**
|
|
115
|
-
* Configuration for log filtering
|
|
116
|
-
*/
|
|
117
47
|
interface LogFilterConfig {
|
|
118
48
|
minLevel?: LogLevel;
|
|
119
49
|
componentPattern?: string;
|
|
120
50
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Provide a log filter with explicit configuration
|
|
123
|
-
* @param config - Filter configuration (minLevel defaults to WARN)
|
|
124
|
-
*/
|
|
125
51
|
declare function provideLogFilterWithConfig(config?: LogFilterConfig): Provider;
|
|
126
|
-
/**
|
|
127
|
-
* @deprecated Use provideLogFilterWithConfig() instead.
|
|
128
|
-
* This function directly accesses process.env which violates the rule
|
|
129
|
-
* that packages should not access environment variables directly.
|
|
130
|
-
*
|
|
131
|
-
* Migration example:
|
|
132
|
-
* ```typescript
|
|
133
|
-
* // Before (in packages)
|
|
134
|
-
* provideLogFilterFromEnv()
|
|
135
|
-
*
|
|
136
|
-
* // After (in application layer)
|
|
137
|
-
* provideLogFilterWithConfig({
|
|
138
|
-
* minLevel: process.env['LOG_LEVEL'] ? LogLevel[process.env['LOG_LEVEL'].toUpperCase()] : undefined,
|
|
139
|
-
* componentPattern: process.env['LOG_COMPONENTS']
|
|
140
|
-
* })
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
52
|
declare function provideLogFilterFromEnv(): Provider;
|
|
144
53
|
|
|
145
54
|
export { BaseLogger, LOGGER, LOG_FILTER, LogLevel, provideLogFilter, provideLogFilterFromEnv, provideLogFilterWithConfig, provideLogger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nx-ddd-logging-base.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"],"sourcesContent":[null,null,null,null],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"nx-ddd-logging-base.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"],"sourcesContent":[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;;;"}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { Provider } from '@angular/core';
|
|
2
2
|
import { LogLevel, BaseLogger, LogContext } from '@nx-ddd/logging/base';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* ConsoleLogger implementation for multi-provider logging
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
4
|
interface ConsoleLoggerOptions {
|
|
9
5
|
minLevel?: LogLevel;
|
|
10
6
|
componentFilter?: string;
|
|
7
|
+
useStderr?: boolean;
|
|
8
|
+
format?: 'legacy' | 'pretty';
|
|
9
|
+
color?: boolean;
|
|
11
10
|
}
|
|
12
11
|
declare class ConsoleLogger extends BaseLogger {
|
|
13
12
|
private readonly minLevel;
|
|
13
|
+
private readonly useStderr;
|
|
14
|
+
private readonly format;
|
|
15
|
+
private readonly color?;
|
|
14
16
|
constructor(options?: ConsoleLoggerOptions);
|
|
15
17
|
log(level: LogLevel, message: string, context?: LogContext, error?: Error): void;
|
|
18
|
+
private detectTty;
|
|
16
19
|
close(): void;
|
|
17
20
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Provide ConsoleLogger with optional configuration
|
|
20
|
-
* @param options - Logger options (minLevel defaults to WARN if not specified)
|
|
21
|
-
*/
|
|
22
21
|
declare function provideConsoleLogger(options?: ConsoleLoggerOptions): Provider;
|
|
23
22
|
|
|
24
23
|
export { ConsoleLogger, provideConsoleLogger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nx-ddd-logging-console.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/console/console.logger.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nx-ddd-logging-console.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/console/console.logger.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAWE;;AAED;AAED;AACE;AACA;AACA;AACA;;AAUA;AA2BA;AAMA;AAGD;AAGD;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InjectionToken, Provider } from '@angular/core';
|
|
2
|
+
import { Logger } from '@nx-ddd/logging';
|
|
3
|
+
|
|
4
|
+
declare const LOG_SCOPE: InjectionToken<string>;
|
|
5
|
+
declare function provideLogScope(segment: string): Provider;
|
|
6
|
+
|
|
7
|
+
interface PackageLoggers {
|
|
8
|
+
injectLogger(component: string): Logger;
|
|
9
|
+
getLogger(component: string): Logger;
|
|
10
|
+
}
|
|
11
|
+
declare function loggerFactory(pkg: string): PackageLoggers;
|
|
12
|
+
|
|
13
|
+
export { LOG_SCOPE, loggerFactory, provideLogScope };
|
|
14
|
+
export type { PackageLoggers };
|
|
15
|
+
//# sourceMappingURL=nx-ddd-logging-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-ddd-logging-factory.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/factory/log-scope.ts","../../../../../packages/@nx-ddd/logging/src/lib/factory/logger-factory.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;;AAEA;AAEA;;;ACCE;AACA;AACD;AAED;;;"}
|
|
@@ -1,42 +1,35 @@
|
|
|
1
1
|
import { LogLevel, BaseLogger, LogContext } from '@nx-ddd/logging/base';
|
|
2
2
|
import { Provider } from '@angular/core';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* FileLogger implementation for multi-provider logging
|
|
6
|
-
*/
|
|
7
|
-
|
|
4
|
+
type FileLogFormat = 'text' | 'json';
|
|
8
5
|
interface FileLoggerOptions {
|
|
9
6
|
filePath?: string;
|
|
10
7
|
logDir?: string;
|
|
11
8
|
component?: string;
|
|
12
9
|
minLevel?: LogLevel;
|
|
13
10
|
componentFilter?: string;
|
|
11
|
+
format?: FileLogFormat;
|
|
14
12
|
}
|
|
15
13
|
declare class FileLogger extends BaseLogger {
|
|
16
14
|
private writeStream;
|
|
17
15
|
private minLevel;
|
|
18
16
|
private componentFilter?;
|
|
19
17
|
private startTime;
|
|
18
|
+
private format;
|
|
20
19
|
constructor(options?: FileLoggerOptions);
|
|
21
20
|
log(level: LogLevel, message: string, context?: LogContext, error?: Error): void;
|
|
22
21
|
close(): void;
|
|
23
22
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Options for provideFileLogger
|
|
26
|
-
*/
|
|
27
23
|
interface FileLoggerProviderOptions {
|
|
28
24
|
component?: string;
|
|
29
25
|
logDir?: string;
|
|
30
26
|
filePath?: string;
|
|
31
27
|
minLevel?: LogLevel;
|
|
32
28
|
componentFilter?: string;
|
|
29
|
+
format?: FileLogFormat;
|
|
33
30
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Provide FileLogger with optional configuration
|
|
36
|
-
* @param options - Logger options (minLevel defaults to DEBUG if not specified)
|
|
37
|
-
*/
|
|
38
31
|
declare function provideFileLogger(options?: FileLoggerProviderOptions): Provider;
|
|
39
32
|
|
|
40
33
|
export { FileLogger, provideFileLogger };
|
|
41
|
-
export type { FileLoggerOptions, FileLoggerProviderOptions };
|
|
34
|
+
export type { FileLogFormat, FileLoggerOptions, FileLoggerProviderOptions };
|
|
42
35
|
//# sourceMappingURL=nx-ddd-logging-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nx-ddd-logging-file.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/file/file-logger.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nx-ddd-logging-file.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/file/file-logger.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AAmBC;AAED;;;;;;;AAsCE;AA4BA;AAMD;;;;;;;;AAUA;AAGD;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LogLevel, LogContext } from '@nx-ddd/logging/base';
|
|
2
|
+
|
|
3
|
+
interface LogRecord {
|
|
4
|
+
ts: string;
|
|
5
|
+
lvl: string;
|
|
6
|
+
component: string;
|
|
7
|
+
package?: string;
|
|
8
|
+
msg: string;
|
|
9
|
+
ctx?: Record<string, unknown>;
|
|
10
|
+
err?: {
|
|
11
|
+
message: string;
|
|
12
|
+
stack?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
declare function buildLogRecord(level: LogLevel, message: string, context?: LogContext, error?: Error, ts?: string): LogRecord;
|
|
16
|
+
declare function formatText(record: LogRecord, opts?: {
|
|
17
|
+
color?: boolean;
|
|
18
|
+
}): string;
|
|
19
|
+
declare function formatJson(record: LogRecord): string;
|
|
20
|
+
|
|
21
|
+
export { buildLogRecord, formatJson, formatText };
|
|
22
|
+
export type { LogRecord };
|
|
23
|
+
//# sourceMappingURL=nx-ddd-logging-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-ddd-logging-format.d.ts","sources":["../../../../../packages/@nx-ddd/logging/src/lib/format/log-record.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AASE;;;;AACD;AAED;AAmCA;;AAAwE;AAqBxE;;;"}
|