@globalart/nestjs-logger 2.3.0 → 2.4.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/dist/index.cjs +68 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -19
- package/dist/index.d.mts +25 -19
- package/dist/index.mjs +63 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as _nestjs_common0 from "@nestjs/common";
|
|
4
4
|
import { CallHandler, DynamicModule, ExecutionContext, LoggerService as LoggerService$1, MiddlewareConsumer, NestInterceptor, NestModule, RequestMethod } from "@nestjs/common";
|
|
5
5
|
import { Reflector } from "@nestjs/core";
|
|
6
|
-
import { ClsService } from "nestjs-cls";
|
|
7
6
|
|
|
8
7
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/types/internal/Subscription.d.ts
|
|
9
8
|
/**
|
|
@@ -353,10 +352,10 @@ declare class Observable<T> implements Subscribable<T> {
|
|
|
353
352
|
}
|
|
354
353
|
//#endregion
|
|
355
354
|
//#region src/types/index.d.ts
|
|
356
|
-
type LogLevel
|
|
355
|
+
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
357
356
|
type LogFormat = "json" | "text" | "pino";
|
|
358
357
|
interface LogEntry {
|
|
359
|
-
readonly level: LogLevel
|
|
358
|
+
readonly level: LogLevel;
|
|
360
359
|
readonly message: string;
|
|
361
360
|
readonly timestamp: Date;
|
|
362
361
|
readonly context?: string;
|
|
@@ -405,7 +404,7 @@ interface ExcludeOption {
|
|
|
405
404
|
path: string;
|
|
406
405
|
}
|
|
407
406
|
interface LoggerConfiguration {
|
|
408
|
-
readonly level: LogLevel
|
|
407
|
+
readonly level: LogLevel;
|
|
409
408
|
readonly timestamp: boolean;
|
|
410
409
|
readonly colors: boolean;
|
|
411
410
|
readonly context?: string;
|
|
@@ -428,7 +427,6 @@ interface ILogFormatter {
|
|
|
428
427
|
format(entry: LogEntry): string;
|
|
429
428
|
formatHttpRequest(entry: HttpRequestLogEntry): string;
|
|
430
429
|
}
|
|
431
|
-
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
432
430
|
interface ILogWriter {
|
|
433
431
|
write(formattedLog: string, level?: LogLevel): void;
|
|
434
432
|
}
|
|
@@ -448,9 +446,8 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
448
446
|
private readonly formatter;
|
|
449
447
|
private readonly writer;
|
|
450
448
|
private readonly contextResolver;
|
|
451
|
-
private readonly clsService;
|
|
452
449
|
private context?;
|
|
453
|
-
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver
|
|
450
|
+
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver);
|
|
454
451
|
setContext(context: string): void;
|
|
455
452
|
log(options: LogOptions): void;
|
|
456
453
|
error(options: LogOptions): void;
|
|
@@ -479,8 +476,6 @@ declare class HttpLoggerInterceptor implements NestInterceptor {
|
|
|
479
476
|
private sanitizeHeaders;
|
|
480
477
|
private getRequestMethod;
|
|
481
478
|
private shouldExcludeRequest;
|
|
482
|
-
private sanitizeGraphQLArgs;
|
|
483
|
-
private getGraphQLResultSize;
|
|
484
479
|
private extractErrorMessage;
|
|
485
480
|
private extractErrorTrace;
|
|
486
481
|
}
|
|
@@ -510,28 +505,39 @@ declare class LoggerModule extends ConfigurableModuleClass implements NestModule
|
|
|
510
505
|
configure(consumer: MiddlewareConsumer): void;
|
|
511
506
|
static forRoot(options?: typeof OPTIONS_TYPE): DynamicModule;
|
|
512
507
|
static forRootAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
|
|
508
|
+
private static readonly BASE_EXPORTS;
|
|
509
|
+
private static createConfigProvider;
|
|
513
510
|
private static createCoreProviders;
|
|
514
511
|
private static createDynamicContextProviders;
|
|
515
512
|
}
|
|
516
513
|
//#endregion
|
|
514
|
+
//#region src/core/trace-context.service.d.ts
|
|
515
|
+
declare class TraceContextService {
|
|
516
|
+
/**
|
|
517
|
+
* Sets trace-id for the current async context.
|
|
518
|
+
* Affects all subsequent logs within the same request/async scope.
|
|
519
|
+
*/
|
|
520
|
+
setTraceId(traceId: string): void;
|
|
521
|
+
/**
|
|
522
|
+
* Returns the current trace-id from the async context.
|
|
523
|
+
*/
|
|
524
|
+
getTraceId(): string | undefined;
|
|
525
|
+
/**
|
|
526
|
+
* Runs a callback in a new isolated async context with the given trace-id.
|
|
527
|
+
* Does not affect the parent context.
|
|
528
|
+
*/
|
|
529
|
+
runWithTraceId<T>(traceId: string, fn: () => T): T;
|
|
530
|
+
}
|
|
531
|
+
//#endregion
|
|
517
532
|
//#region src/constants/index.d.ts
|
|
518
533
|
declare const LOGGER_CONTEXT_METADATA: unique symbol;
|
|
519
534
|
declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
520
535
|
declare const LOGGER_EXCLUDE_METADATA: unique symbol;
|
|
521
536
|
//#endregion
|
|
522
537
|
//#region src/decorators/index.d.ts
|
|
523
|
-
/**
|
|
524
|
-
* Decorator to set logging context for a class or method
|
|
525
|
-
*/
|
|
526
538
|
declare const LogContext: (context: string) => _nestjs_common0.CustomDecorator<typeof LOGGER_CONTEXT_METADATA>;
|
|
527
|
-
/**
|
|
528
|
-
* Decorator to add metadata to logs
|
|
529
|
-
*/
|
|
530
539
|
declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common0.CustomDecorator<typeof LOGGER_METADATA_METADATA>;
|
|
531
|
-
/**
|
|
532
|
-
* Decorator to exclude logging for a controller or method
|
|
533
|
-
*/
|
|
534
540
|
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
535
541
|
//#endregion
|
|
536
|
-
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService };
|
|
542
|
+
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService, TraceContextService };
|
|
537
543
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as _nestjs_common0 from "@nestjs/common";
|
|
4
4
|
import { CallHandler, DynamicModule, ExecutionContext, LoggerService as LoggerService$1, MiddlewareConsumer, NestInterceptor, NestModule, RequestMethod } from "@nestjs/common";
|
|
5
5
|
import { Reflector } from "@nestjs/core";
|
|
6
|
-
import { ClsService } from "nestjs-cls";
|
|
7
6
|
|
|
8
7
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/types/internal/Subscription.d.ts
|
|
9
8
|
/**
|
|
@@ -353,10 +352,10 @@ declare class Observable<T> implements Subscribable<T> {
|
|
|
353
352
|
}
|
|
354
353
|
//#endregion
|
|
355
354
|
//#region src/types/index.d.ts
|
|
356
|
-
type LogLevel
|
|
355
|
+
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
357
356
|
type LogFormat = "json" | "text" | "pino";
|
|
358
357
|
interface LogEntry {
|
|
359
|
-
readonly level: LogLevel
|
|
358
|
+
readonly level: LogLevel;
|
|
360
359
|
readonly message: string;
|
|
361
360
|
readonly timestamp: Date;
|
|
362
361
|
readonly context?: string;
|
|
@@ -405,7 +404,7 @@ interface ExcludeOption {
|
|
|
405
404
|
path: string;
|
|
406
405
|
}
|
|
407
406
|
interface LoggerConfiguration {
|
|
408
|
-
readonly level: LogLevel
|
|
407
|
+
readonly level: LogLevel;
|
|
409
408
|
readonly timestamp: boolean;
|
|
410
409
|
readonly colors: boolean;
|
|
411
410
|
readonly context?: string;
|
|
@@ -428,7 +427,6 @@ interface ILogFormatter {
|
|
|
428
427
|
format(entry: LogEntry): string;
|
|
429
428
|
formatHttpRequest(entry: HttpRequestLogEntry): string;
|
|
430
429
|
}
|
|
431
|
-
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
432
430
|
interface ILogWriter {
|
|
433
431
|
write(formattedLog: string, level?: LogLevel): void;
|
|
434
432
|
}
|
|
@@ -448,9 +446,8 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
448
446
|
private readonly formatter;
|
|
449
447
|
private readonly writer;
|
|
450
448
|
private readonly contextResolver;
|
|
451
|
-
private readonly clsService;
|
|
452
449
|
private context?;
|
|
453
|
-
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver
|
|
450
|
+
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver);
|
|
454
451
|
setContext(context: string): void;
|
|
455
452
|
log(options: LogOptions): void;
|
|
456
453
|
error(options: LogOptions): void;
|
|
@@ -479,8 +476,6 @@ declare class HttpLoggerInterceptor implements NestInterceptor {
|
|
|
479
476
|
private sanitizeHeaders;
|
|
480
477
|
private getRequestMethod;
|
|
481
478
|
private shouldExcludeRequest;
|
|
482
|
-
private sanitizeGraphQLArgs;
|
|
483
|
-
private getGraphQLResultSize;
|
|
484
479
|
private extractErrorMessage;
|
|
485
480
|
private extractErrorTrace;
|
|
486
481
|
}
|
|
@@ -510,28 +505,39 @@ declare class LoggerModule extends ConfigurableModuleClass implements NestModule
|
|
|
510
505
|
configure(consumer: MiddlewareConsumer): void;
|
|
511
506
|
static forRoot(options?: typeof OPTIONS_TYPE): DynamicModule;
|
|
512
507
|
static forRootAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
|
|
508
|
+
private static readonly BASE_EXPORTS;
|
|
509
|
+
private static createConfigProvider;
|
|
513
510
|
private static createCoreProviders;
|
|
514
511
|
private static createDynamicContextProviders;
|
|
515
512
|
}
|
|
516
513
|
//#endregion
|
|
514
|
+
//#region src/core/trace-context.service.d.ts
|
|
515
|
+
declare class TraceContextService {
|
|
516
|
+
/**
|
|
517
|
+
* Sets trace-id for the current async context.
|
|
518
|
+
* Affects all subsequent logs within the same request/async scope.
|
|
519
|
+
*/
|
|
520
|
+
setTraceId(traceId: string): void;
|
|
521
|
+
/**
|
|
522
|
+
* Returns the current trace-id from the async context.
|
|
523
|
+
*/
|
|
524
|
+
getTraceId(): string | undefined;
|
|
525
|
+
/**
|
|
526
|
+
* Runs a callback in a new isolated async context with the given trace-id.
|
|
527
|
+
* Does not affect the parent context.
|
|
528
|
+
*/
|
|
529
|
+
runWithTraceId<T>(traceId: string, fn: () => T): T;
|
|
530
|
+
}
|
|
531
|
+
//#endregion
|
|
517
532
|
//#region src/constants/index.d.ts
|
|
518
533
|
declare const LOGGER_CONTEXT_METADATA: unique symbol;
|
|
519
534
|
declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
520
535
|
declare const LOGGER_EXCLUDE_METADATA: unique symbol;
|
|
521
536
|
//#endregion
|
|
522
537
|
//#region src/decorators/index.d.ts
|
|
523
|
-
/**
|
|
524
|
-
* Decorator to set logging context for a class or method
|
|
525
|
-
*/
|
|
526
538
|
declare const LogContext: (context: string) => _nestjs_common0.CustomDecorator<typeof LOGGER_CONTEXT_METADATA>;
|
|
527
|
-
/**
|
|
528
|
-
* Decorator to add metadata to logs
|
|
529
|
-
*/
|
|
530
539
|
declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common0.CustomDecorator<typeof LOGGER_METADATA_METADATA>;
|
|
531
|
-
/**
|
|
532
|
-
* Decorator to exclude logging for a controller or method
|
|
533
|
-
*/
|
|
534
540
|
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
535
541
|
//#endregion
|
|
536
|
-
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService };
|
|
542
|
+
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService, TraceContextService };
|
|
537
543
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { ConfigurableModuleBuilder, Inject, Injectable, Module, RequestMethod, SetMetadata } from "@nestjs/common";
|
|
3
3
|
import { APP_INTERCEPTOR, Reflector } from "@nestjs/core";
|
|
4
4
|
import { hostname } from "os";
|
|
5
|
-
import { ClsService } from "nestjs-cls";
|
|
6
5
|
import { AsyncLocalStorage } from "async_hooks";
|
|
7
6
|
import { nanoid } from "nanoid";
|
|
8
7
|
import { randomBytes, randomUUID } from "crypto";
|
|
@@ -7089,7 +7088,6 @@ function __decorate(decorators, target, key, desc) {
|
|
|
7089
7088
|
}
|
|
7090
7089
|
//#endregion
|
|
7091
7090
|
//#region src/core/logger.service.ts
|
|
7092
|
-
var _ref$2;
|
|
7093
7091
|
const PINO_LEVEL_TO_LOG_LEVEL = {
|
|
7094
7092
|
60: "error",
|
|
7095
7093
|
50: "error",
|
|
@@ -7100,12 +7098,11 @@ const PINO_LEVEL_TO_LOG_LEVEL = {
|
|
|
7100
7098
|
};
|
|
7101
7099
|
let LoggerService = class LoggerService {
|
|
7102
7100
|
context;
|
|
7103
|
-
constructor(config, formatter, writer, contextResolver
|
|
7101
|
+
constructor(config, formatter, writer, contextResolver) {
|
|
7104
7102
|
this.config = config;
|
|
7105
7103
|
this.formatter = formatter;
|
|
7106
7104
|
this.writer = writer;
|
|
7107
7105
|
this.contextResolver = contextResolver;
|
|
7108
|
-
this.clsService = clsService;
|
|
7109
7106
|
}
|
|
7110
7107
|
setContext(context) {
|
|
7111
7108
|
this.context = context;
|
|
@@ -7167,8 +7164,7 @@ LoggerService = __decorate([Injectable(), __decorateMetadata("design:paramtypes"
|
|
|
7167
7164
|
Object,
|
|
7168
7165
|
Object,
|
|
7169
7166
|
Object,
|
|
7170
|
-
Object
|
|
7171
|
-
typeof (_ref$2 = typeof ClsService !== "undefined" && ClsService) === "function" ? _ref$2 : Object
|
|
7167
|
+
Object
|
|
7172
7168
|
])], LoggerService);
|
|
7173
7169
|
//#endregion
|
|
7174
7170
|
//#region \0@oxc-project+runtime@0.115.0/helpers/decorateParam.js
|
|
@@ -7180,9 +7176,6 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
7180
7176
|
//#endregion
|
|
7181
7177
|
//#region src/core/http-logger.interceptor.ts
|
|
7182
7178
|
var _ref$1, _ref2$1;
|
|
7183
|
-
try {
|
|
7184
|
-
__require("@nestjs/graphql").GqlExecutionContext;
|
|
7185
|
-
} catch {}
|
|
7186
7179
|
let HttpLoggerInterceptor = class HttpLoggerInterceptor {
|
|
7187
7180
|
hostname = hostname();
|
|
7188
7181
|
pid = process.pid;
|
|
@@ -7194,6 +7187,7 @@ let HttpLoggerInterceptor = class HttpLoggerInterceptor {
|
|
|
7194
7187
|
this.reflector = reflector;
|
|
7195
7188
|
}
|
|
7196
7189
|
intercept(context, next) {
|
|
7190
|
+
if (!this.config.logRequests) return next.handle();
|
|
7197
7191
|
const request = context.switchToHttp().getRequest();
|
|
7198
7192
|
const response = context.switchToHttp().getResponse();
|
|
7199
7193
|
if (!request || !request.method) return next.handle();
|
|
@@ -7305,20 +7299,6 @@ let HttpLoggerInterceptor = class HttpLoggerInterceptor {
|
|
|
7305
7299
|
return path === excludeOption.path;
|
|
7306
7300
|
});
|
|
7307
7301
|
}
|
|
7308
|
-
sanitizeGraphQLArgs(args) {
|
|
7309
|
-
if (!args || typeof args !== "object") return args;
|
|
7310
|
-
const sanitized = { ...args };
|
|
7311
|
-
if (sanitized.input && sanitized.input.password) sanitized.input = {
|
|
7312
|
-
...sanitized.input,
|
|
7313
|
-
password: "[HIDDEN]"
|
|
7314
|
-
};
|
|
7315
|
-
return this.dataSanitizer.sanitize(sanitized);
|
|
7316
|
-
}
|
|
7317
|
-
getGraphQLResultSize(result) {
|
|
7318
|
-
if (Array.isArray(result)) return `${result.length} items`;
|
|
7319
|
-
if (result && typeof result === "object") return "1 object";
|
|
7320
|
-
return "primitive";
|
|
7321
|
-
}
|
|
7322
7302
|
extractErrorMessage(error) {
|
|
7323
7303
|
if (!error) return void 0;
|
|
7324
7304
|
if (typeof error.getResponse === "function") {
|
|
@@ -7500,20 +7480,17 @@ let PinoFormatter = class PinoFormatter extends BaseFormatter {
|
|
|
7500
7480
|
const obj = {
|
|
7501
7481
|
level: entry.level,
|
|
7502
7482
|
message: entry.message,
|
|
7503
|
-
timestamp: entry.timestamp
|
|
7504
|
-
context: entry.context,
|
|
7505
|
-
metadata: entry.metadata,
|
|
7506
|
-
trace: entry.trace
|
|
7483
|
+
timestamp: entry.timestamp
|
|
7507
7484
|
};
|
|
7485
|
+
if (entry.context) obj.context = entry.context;
|
|
7486
|
+
if (entry.metadata) obj.metadata = entry.metadata;
|
|
7487
|
+
if (entry.trace) obj.trace = entry.trace;
|
|
7508
7488
|
if (entry.traceId) obj.traceId = entry.traceId;
|
|
7509
7489
|
if (entry.spanId) obj.spanId = entry.spanId;
|
|
7510
7490
|
return JSON.stringify(obj);
|
|
7511
7491
|
}
|
|
7512
7492
|
formatHttpRequest(entry) {
|
|
7513
|
-
const
|
|
7514
|
-
if (entry.traceId) obj.traceId = entry.traceId;
|
|
7515
|
-
if (entry.spanId) obj.spanId = entry.spanId;
|
|
7516
|
-
const jsonString = JSON.stringify(obj);
|
|
7493
|
+
const jsonString = JSON.stringify(entry);
|
|
7517
7494
|
return this.options.colors ? this.colorize(jsonString, this.getColorForLevel(entry.level)) : jsonString;
|
|
7518
7495
|
}
|
|
7519
7496
|
};
|
|
@@ -7680,6 +7657,32 @@ let TraceContextMiddleware = class TraceContextMiddleware {
|
|
|
7680
7657
|
};
|
|
7681
7658
|
TraceContextMiddleware = __decorate([Injectable()], TraceContextMiddleware);
|
|
7682
7659
|
//#endregion
|
|
7660
|
+
//#region src/core/trace-context.service.ts
|
|
7661
|
+
let TraceContextService = class TraceContextService {
|
|
7662
|
+
/**
|
|
7663
|
+
* Sets trace-id for the current async context.
|
|
7664
|
+
* Affects all subsequent logs within the same request/async scope.
|
|
7665
|
+
*/
|
|
7666
|
+
setTraceId(traceId) {
|
|
7667
|
+
const store = traceContextStorage.getStore();
|
|
7668
|
+
if (store) store.correlationId = traceId;
|
|
7669
|
+
}
|
|
7670
|
+
/**
|
|
7671
|
+
* Returns the current trace-id from the async context.
|
|
7672
|
+
*/
|
|
7673
|
+
getTraceId() {
|
|
7674
|
+
return traceContextStorage.getStore()?.correlationId;
|
|
7675
|
+
}
|
|
7676
|
+
/**
|
|
7677
|
+
* Runs a callback in a new isolated async context with the given trace-id.
|
|
7678
|
+
* Does not affect the parent context.
|
|
7679
|
+
*/
|
|
7680
|
+
runWithTraceId(traceId, fn) {
|
|
7681
|
+
return traceContextStorage.run({ correlationId: traceId }, fn);
|
|
7682
|
+
}
|
|
7683
|
+
};
|
|
7684
|
+
TraceContextService = __decorate([Injectable()], TraceContextService);
|
|
7685
|
+
//#endregion
|
|
7683
7686
|
//#region src/core/logger.module.ts
|
|
7684
7687
|
const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new ConfigurableModuleBuilder().setClassMethodName("forRoot").setExtras({ global: true }, (definition, extras) => ({
|
|
7685
7688
|
...definition,
|
|
@@ -7698,27 +7701,11 @@ let LoggerModule = class LoggerModule extends ConfigurableModuleClass {
|
|
|
7698
7701
|
...parent.providers ?? [],
|
|
7699
7702
|
...this.createCoreProviders(),
|
|
7700
7703
|
...contextProviders,
|
|
7701
|
-
|
|
7702
|
-
provide: LOGGER_CONFIG_TOKEN,
|
|
7703
|
-
useFactory: (opts) => ({
|
|
7704
|
-
...DEFAULT_LOGGER_CONFIG,
|
|
7705
|
-
...opts,
|
|
7706
|
-
sensitiveFields: opts.sensitiveFields ?? DEFAULT_LOGGER_CONFIG.sensitiveFields,
|
|
7707
|
-
exclude: opts.exclude ?? DEFAULT_LOGGER_CONFIG.exclude
|
|
7708
|
-
}),
|
|
7709
|
-
inject: [MODULE_OPTIONS_TOKEN]
|
|
7710
|
-
},
|
|
7711
|
-
...options.logRequests ? [{
|
|
7712
|
-
provide: APP_INTERCEPTOR,
|
|
7713
|
-
useExisting: HttpLoggerInterceptor
|
|
7714
|
-
}] : []
|
|
7704
|
+
this.createConfigProvider()
|
|
7715
7705
|
],
|
|
7716
7706
|
exports: [
|
|
7717
7707
|
...parent.exports ?? [],
|
|
7718
|
-
|
|
7719
|
-
HttpLoggerInterceptor,
|
|
7720
|
-
DYNAMIC_CONTEXT_LOGGER_FACTORY_TOKEN,
|
|
7721
|
-
TraceContextMiddleware,
|
|
7708
|
+
...this.BASE_EXPORTS,
|
|
7722
7709
|
...contextProviders.map((p) => p.provide)
|
|
7723
7710
|
]
|
|
7724
7711
|
};
|
|
@@ -7732,35 +7719,38 @@ let LoggerModule = class LoggerModule extends ConfigurableModuleClass {
|
|
|
7732
7719
|
...parent.providers ?? [],
|
|
7733
7720
|
...this.createCoreProviders(),
|
|
7734
7721
|
...contextProviders,
|
|
7735
|
-
|
|
7736
|
-
provide: LOGGER_CONFIG_TOKEN,
|
|
7737
|
-
useFactory: (opts) => ({
|
|
7738
|
-
...DEFAULT_LOGGER_CONFIG,
|
|
7739
|
-
...opts,
|
|
7740
|
-
sensitiveFields: opts.sensitiveFields ?? DEFAULT_LOGGER_CONFIG.sensitiveFields,
|
|
7741
|
-
exclude: opts.exclude ?? DEFAULT_LOGGER_CONFIG.exclude
|
|
7742
|
-
}),
|
|
7743
|
-
inject: [MODULE_OPTIONS_TOKEN]
|
|
7744
|
-
},
|
|
7745
|
-
{
|
|
7746
|
-
provide: APP_INTERCEPTOR,
|
|
7747
|
-
useFactory: (config, interceptor) => config.logRequests ? interceptor : null,
|
|
7748
|
-
inject: [LOGGER_CONFIG_TOKEN, HttpLoggerInterceptor]
|
|
7749
|
-
}
|
|
7722
|
+
this.createConfigProvider()
|
|
7750
7723
|
],
|
|
7751
7724
|
exports: [
|
|
7752
7725
|
...parent.exports ?? [],
|
|
7753
|
-
|
|
7754
|
-
HttpLoggerInterceptor,
|
|
7755
|
-
DYNAMIC_CONTEXT_LOGGER_FACTORY_TOKEN,
|
|
7756
|
-
TraceContextMiddleware,
|
|
7726
|
+
...this.BASE_EXPORTS,
|
|
7757
7727
|
...contextProviders.map((p) => p.provide)
|
|
7758
7728
|
]
|
|
7759
7729
|
};
|
|
7760
7730
|
}
|
|
7731
|
+
static BASE_EXPORTS = [
|
|
7732
|
+
LOGGER_SERVICE_TOKEN,
|
|
7733
|
+
HttpLoggerInterceptor,
|
|
7734
|
+
DYNAMIC_CONTEXT_LOGGER_FACTORY_TOKEN,
|
|
7735
|
+
TraceContextMiddleware,
|
|
7736
|
+
TraceContextService
|
|
7737
|
+
];
|
|
7738
|
+
static createConfigProvider() {
|
|
7739
|
+
return {
|
|
7740
|
+
provide: LOGGER_CONFIG_TOKEN,
|
|
7741
|
+
useFactory: (opts) => ({
|
|
7742
|
+
...DEFAULT_LOGGER_CONFIG,
|
|
7743
|
+
...opts,
|
|
7744
|
+
sensitiveFields: opts.sensitiveFields ?? DEFAULT_LOGGER_CONFIG.sensitiveFields,
|
|
7745
|
+
exclude: opts.exclude ?? DEFAULT_LOGGER_CONFIG.exclude
|
|
7746
|
+
}),
|
|
7747
|
+
inject: [MODULE_OPTIONS_TOKEN]
|
|
7748
|
+
};
|
|
7749
|
+
}
|
|
7761
7750
|
static createCoreProviders() {
|
|
7762
7751
|
return [
|
|
7763
7752
|
TraceContextMiddleware,
|
|
7753
|
+
TraceContextService,
|
|
7764
7754
|
FormatterFactory,
|
|
7765
7755
|
ConsoleWriter,
|
|
7766
7756
|
ContextResolver,
|
|
@@ -7799,6 +7789,10 @@ let LoggerModule = class LoggerModule extends ConfigurableModuleClass {
|
|
|
7799
7789
|
RequestIdGenerator,
|
|
7800
7790
|
LOGGER_CONFIG_TOKEN
|
|
7801
7791
|
]
|
|
7792
|
+
},
|
|
7793
|
+
{
|
|
7794
|
+
provide: APP_INTERCEPTOR,
|
|
7795
|
+
useExisting: HttpLoggerInterceptor
|
|
7802
7796
|
}
|
|
7803
7797
|
];
|
|
7804
7798
|
}
|
|
@@ -7813,19 +7807,10 @@ let LoggerModule = class LoggerModule extends ConfigurableModuleClass {
|
|
|
7813
7807
|
LoggerModule = __decorate([Module({})], LoggerModule);
|
|
7814
7808
|
//#endregion
|
|
7815
7809
|
//#region src/decorators/index.ts
|
|
7816
|
-
/**
|
|
7817
|
-
* Decorator to set logging context for a class or method
|
|
7818
|
-
*/
|
|
7819
7810
|
const LogContext = (context) => SetMetadata(LOGGER_CONTEXT_METADATA, context);
|
|
7820
|
-
/**
|
|
7821
|
-
* Decorator to add metadata to logs
|
|
7822
|
-
*/
|
|
7823
7811
|
const LogMetadata = (metadata) => SetMetadata(LOGGER_METADATA_METADATA, metadata);
|
|
7824
|
-
/**
|
|
7825
|
-
* Decorator to exclude logging for a controller or method
|
|
7826
|
-
*/
|
|
7827
7812
|
const ExcludeLogging = () => SetMetadata(LOGGER_EXCLUDE_METADATA, true);
|
|
7828
7813
|
//#endregion
|
|
7829
|
-
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService };
|
|
7814
|
+
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService, TraceContextService };
|
|
7830
7815
|
|
|
7831
7816
|
//# sourceMappingURL=index.mjs.map
|