@globalart/nestjs-logger 1.4.2 → 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 +157 -468
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -90
- package/dist/index.d.mts +34 -90
- package/dist/index.mjs +137 -446
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -11
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="operators/index.d.ts" />
|
|
2
2
|
/// <reference path="testing/index.d.ts" />
|
|
3
3
|
import * as _nestjs_common0 from "@nestjs/common";
|
|
4
|
-
import { CallHandler, DynamicModule, ExecutionContext, LoggerService as LoggerService$1, NestInterceptor, RequestMethod } from "@nestjs/common";
|
|
4
|
+
import { CallHandler, DynamicModule, ExecutionContext, LoggerService as LoggerService$1, MiddlewareConsumer, NestInterceptor, NestModule, RequestMethod } from "@nestjs/common";
|
|
5
5
|
import { Reflector } from "@nestjs/core";
|
|
6
6
|
|
|
7
7
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/types/internal/Subscription.d.ts
|
|
@@ -352,12 +352,10 @@ declare class Observable<T> implements Subscribable<T> {
|
|
|
352
352
|
}
|
|
353
353
|
//#endregion
|
|
354
354
|
//#region src/types/index.d.ts
|
|
355
|
-
type LogLevel
|
|
355
|
+
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
356
356
|
type LogFormat = "json" | "text" | "pino";
|
|
357
|
-
declare const LOG_LEVELS: Record<LogLevel$1, number>;
|
|
358
|
-
declare const PINO_LEVELS: Record<number, string>;
|
|
359
357
|
interface LogEntry {
|
|
360
|
-
readonly level: LogLevel
|
|
358
|
+
readonly level: LogLevel;
|
|
361
359
|
readonly message: string;
|
|
362
360
|
readonly timestamp: Date;
|
|
363
361
|
readonly context?: string;
|
|
@@ -406,7 +404,7 @@ interface ExcludeOption {
|
|
|
406
404
|
path: string;
|
|
407
405
|
}
|
|
408
406
|
interface LoggerConfiguration {
|
|
409
|
-
readonly level: LogLevel
|
|
407
|
+
readonly level: LogLevel;
|
|
410
408
|
readonly timestamp: boolean;
|
|
411
409
|
readonly colors: boolean;
|
|
412
410
|
readonly context?: string;
|
|
@@ -415,39 +413,6 @@ interface LoggerConfiguration {
|
|
|
415
413
|
readonly exclude: readonly ExcludeOption[];
|
|
416
414
|
readonly logRequests?: boolean;
|
|
417
415
|
}
|
|
418
|
-
interface FormatterOptions {
|
|
419
|
-
readonly colors: boolean;
|
|
420
|
-
readonly timestamp: boolean;
|
|
421
|
-
readonly context?: string;
|
|
422
|
-
}
|
|
423
|
-
interface LoggerOptions {
|
|
424
|
-
level?: LogLevel$1;
|
|
425
|
-
timestamp?: boolean;
|
|
426
|
-
colors?: boolean;
|
|
427
|
-
context?: string;
|
|
428
|
-
format?: LogFormat;
|
|
429
|
-
transports?: LoggerTransport[];
|
|
430
|
-
pino?: PinoOptions;
|
|
431
|
-
}
|
|
432
|
-
interface PinoOptions {
|
|
433
|
-
level?: string;
|
|
434
|
-
timestamp?: boolean;
|
|
435
|
-
base?: boolean;
|
|
436
|
-
name?: string;
|
|
437
|
-
enabled?: boolean;
|
|
438
|
-
}
|
|
439
|
-
interface LoggerTransport {
|
|
440
|
-
name: string;
|
|
441
|
-
level?: string;
|
|
442
|
-
format?: unknown;
|
|
443
|
-
filename?: string;
|
|
444
|
-
dirname?: string;
|
|
445
|
-
maxsize?: number;
|
|
446
|
-
maxFiles?: number;
|
|
447
|
-
}
|
|
448
|
-
interface LoggerMetadata {
|
|
449
|
-
[key: string]: unknown;
|
|
450
|
-
}
|
|
451
416
|
//#endregion
|
|
452
417
|
//#region src/contracts/index.d.ts
|
|
453
418
|
interface ILogger {
|
|
@@ -462,7 +427,6 @@ interface ILogFormatter {
|
|
|
462
427
|
format(entry: LogEntry): string;
|
|
463
428
|
formatHttpRequest(entry: HttpRequestLogEntry): string;
|
|
464
429
|
}
|
|
465
|
-
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
466
430
|
interface ILogWriter {
|
|
467
431
|
write(formattedLog: string, level?: LogLevel): void;
|
|
468
432
|
}
|
|
@@ -493,7 +457,6 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
493
457
|
logHttpRequest(entry: HttpRequestLogEntry): void;
|
|
494
458
|
private writeLog;
|
|
495
459
|
private resolveTraceIds;
|
|
496
|
-
private enrichWithTraceIds;
|
|
497
460
|
}
|
|
498
461
|
//#endregion
|
|
499
462
|
//#region src/core/http-logger.interceptor.d.ts
|
|
@@ -507,15 +470,12 @@ declare class HttpLoggerInterceptor implements NestInterceptor {
|
|
|
507
470
|
private readonly pid;
|
|
508
471
|
constructor(logger: LoggerService, dataSanitizer: IDataSanitizer, requestIdGenerator: IRequestIdGenerator, config: LoggerConfiguration, reflector: Reflector);
|
|
509
472
|
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
510
|
-
private handleGraphQLRequest;
|
|
511
473
|
private createHttpLogEntry;
|
|
512
474
|
private createLogEntry;
|
|
513
475
|
private getClientIp;
|
|
514
476
|
private sanitizeHeaders;
|
|
515
477
|
private getRequestMethod;
|
|
516
478
|
private shouldExcludeRequest;
|
|
517
|
-
private sanitizeGraphQLArgs;
|
|
518
|
-
private getGraphQLResultSize;
|
|
519
479
|
private extractErrorMessage;
|
|
520
480
|
private extractErrorTrace;
|
|
521
481
|
}
|
|
@@ -534,46 +494,39 @@ interface LoggerModuleOptions {
|
|
|
534
494
|
exclude?: ExcludeOption[];
|
|
535
495
|
logRequests?: boolean;
|
|
536
496
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
497
|
+
declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<LoggerModuleOptions, "forRoot", "create", {
|
|
498
|
+
global: boolean;
|
|
499
|
+
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: LoggerModuleOptions & Partial<{
|
|
500
|
+
global: boolean;
|
|
501
|
+
}>, ASYNC_OPTIONS_TYPE: _nestjs_common0.ConfigurableModuleAsyncOptions<LoggerModuleOptions, "create"> & Partial<{
|
|
502
|
+
global: boolean;
|
|
503
|
+
}>;
|
|
504
|
+
declare class LoggerModule extends ConfigurableModuleClass implements NestModule {
|
|
505
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
506
|
+
static forRoot(options?: typeof OPTIONS_TYPE): DynamicModule;
|
|
507
|
+
static forRootAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
|
|
508
|
+
private static readonly BASE_EXPORTS;
|
|
509
|
+
private static createConfigProvider;
|
|
546
510
|
private static createCoreProviders;
|
|
547
511
|
private static createDynamicContextProviders;
|
|
548
512
|
}
|
|
549
513
|
//#endregion
|
|
550
|
-
//#region src/
|
|
551
|
-
declare class
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region src/factories/dynamic-context-logger.factory.d.ts
|
|
569
|
-
declare class DynamicContextLoggerFactory {
|
|
570
|
-
private readonly config;
|
|
571
|
-
private readonly formatterFactory;
|
|
572
|
-
private readonly writer;
|
|
573
|
-
private readonly contextResolver;
|
|
574
|
-
private readonly loggerCache;
|
|
575
|
-
constructor(config: LoggerConfiguration, formatterFactory: FormatterFactory, writer: ConsoleWriter, contextResolver: ContextResolver);
|
|
576
|
-
createLogger(context: string): LoggerService;
|
|
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;
|
|
577
530
|
}
|
|
578
531
|
//#endregion
|
|
579
532
|
//#region src/constants/index.d.ts
|
|
@@ -582,18 +535,9 @@ declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
|
582
535
|
declare const LOGGER_EXCLUDE_METADATA: unique symbol;
|
|
583
536
|
//#endregion
|
|
584
537
|
//#region src/decorators/index.d.ts
|
|
585
|
-
/**
|
|
586
|
-
* Decorator to set logging context for a class or method
|
|
587
|
-
*/
|
|
588
538
|
declare const LogContext: (context: string) => _nestjs_common0.CustomDecorator<typeof LOGGER_CONTEXT_METADATA>;
|
|
589
|
-
/**
|
|
590
|
-
* Decorator to add metadata to logs
|
|
591
|
-
*/
|
|
592
539
|
declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common0.CustomDecorator<typeof LOGGER_METADATA_METADATA>;
|
|
593
|
-
/**
|
|
594
|
-
* Decorator to exclude logging for a controller or method
|
|
595
|
-
*/
|
|
596
540
|
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
597
541
|
//#endregion
|
|
598
|
-
export {
|
|
542
|
+
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService, TraceContextService };
|
|
599
543
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="operators/index.d.ts" />
|
|
2
2
|
/// <reference path="testing/index.d.ts" />
|
|
3
3
|
import * as _nestjs_common0 from "@nestjs/common";
|
|
4
|
-
import { CallHandler, DynamicModule, ExecutionContext, LoggerService as LoggerService$1, NestInterceptor, RequestMethod } from "@nestjs/common";
|
|
4
|
+
import { CallHandler, DynamicModule, ExecutionContext, LoggerService as LoggerService$1, MiddlewareConsumer, NestInterceptor, NestModule, RequestMethod } from "@nestjs/common";
|
|
5
5
|
import { Reflector } from "@nestjs/core";
|
|
6
6
|
|
|
7
7
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/types/internal/Subscription.d.ts
|
|
@@ -352,12 +352,10 @@ declare class Observable<T> implements Subscribable<T> {
|
|
|
352
352
|
}
|
|
353
353
|
//#endregion
|
|
354
354
|
//#region src/types/index.d.ts
|
|
355
|
-
type LogLevel
|
|
355
|
+
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
356
356
|
type LogFormat = "json" | "text" | "pino";
|
|
357
|
-
declare const LOG_LEVELS: Record<LogLevel$1, number>;
|
|
358
|
-
declare const PINO_LEVELS: Record<number, string>;
|
|
359
357
|
interface LogEntry {
|
|
360
|
-
readonly level: LogLevel
|
|
358
|
+
readonly level: LogLevel;
|
|
361
359
|
readonly message: string;
|
|
362
360
|
readonly timestamp: Date;
|
|
363
361
|
readonly context?: string;
|
|
@@ -406,7 +404,7 @@ interface ExcludeOption {
|
|
|
406
404
|
path: string;
|
|
407
405
|
}
|
|
408
406
|
interface LoggerConfiguration {
|
|
409
|
-
readonly level: LogLevel
|
|
407
|
+
readonly level: LogLevel;
|
|
410
408
|
readonly timestamp: boolean;
|
|
411
409
|
readonly colors: boolean;
|
|
412
410
|
readonly context?: string;
|
|
@@ -415,39 +413,6 @@ interface LoggerConfiguration {
|
|
|
415
413
|
readonly exclude: readonly ExcludeOption[];
|
|
416
414
|
readonly logRequests?: boolean;
|
|
417
415
|
}
|
|
418
|
-
interface FormatterOptions {
|
|
419
|
-
readonly colors: boolean;
|
|
420
|
-
readonly timestamp: boolean;
|
|
421
|
-
readonly context?: string;
|
|
422
|
-
}
|
|
423
|
-
interface LoggerOptions {
|
|
424
|
-
level?: LogLevel$1;
|
|
425
|
-
timestamp?: boolean;
|
|
426
|
-
colors?: boolean;
|
|
427
|
-
context?: string;
|
|
428
|
-
format?: LogFormat;
|
|
429
|
-
transports?: LoggerTransport[];
|
|
430
|
-
pino?: PinoOptions;
|
|
431
|
-
}
|
|
432
|
-
interface PinoOptions {
|
|
433
|
-
level?: string;
|
|
434
|
-
timestamp?: boolean;
|
|
435
|
-
base?: boolean;
|
|
436
|
-
name?: string;
|
|
437
|
-
enabled?: boolean;
|
|
438
|
-
}
|
|
439
|
-
interface LoggerTransport {
|
|
440
|
-
name: string;
|
|
441
|
-
level?: string;
|
|
442
|
-
format?: unknown;
|
|
443
|
-
filename?: string;
|
|
444
|
-
dirname?: string;
|
|
445
|
-
maxsize?: number;
|
|
446
|
-
maxFiles?: number;
|
|
447
|
-
}
|
|
448
|
-
interface LoggerMetadata {
|
|
449
|
-
[key: string]: unknown;
|
|
450
|
-
}
|
|
451
416
|
//#endregion
|
|
452
417
|
//#region src/contracts/index.d.ts
|
|
453
418
|
interface ILogger {
|
|
@@ -462,7 +427,6 @@ interface ILogFormatter {
|
|
|
462
427
|
format(entry: LogEntry): string;
|
|
463
428
|
formatHttpRequest(entry: HttpRequestLogEntry): string;
|
|
464
429
|
}
|
|
465
|
-
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
466
430
|
interface ILogWriter {
|
|
467
431
|
write(formattedLog: string, level?: LogLevel): void;
|
|
468
432
|
}
|
|
@@ -493,7 +457,6 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
493
457
|
logHttpRequest(entry: HttpRequestLogEntry): void;
|
|
494
458
|
private writeLog;
|
|
495
459
|
private resolveTraceIds;
|
|
496
|
-
private enrichWithTraceIds;
|
|
497
460
|
}
|
|
498
461
|
//#endregion
|
|
499
462
|
//#region src/core/http-logger.interceptor.d.ts
|
|
@@ -507,15 +470,12 @@ declare class HttpLoggerInterceptor implements NestInterceptor {
|
|
|
507
470
|
private readonly pid;
|
|
508
471
|
constructor(logger: LoggerService, dataSanitizer: IDataSanitizer, requestIdGenerator: IRequestIdGenerator, config: LoggerConfiguration, reflector: Reflector);
|
|
509
472
|
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
510
|
-
private handleGraphQLRequest;
|
|
511
473
|
private createHttpLogEntry;
|
|
512
474
|
private createLogEntry;
|
|
513
475
|
private getClientIp;
|
|
514
476
|
private sanitizeHeaders;
|
|
515
477
|
private getRequestMethod;
|
|
516
478
|
private shouldExcludeRequest;
|
|
517
|
-
private sanitizeGraphQLArgs;
|
|
518
|
-
private getGraphQLResultSize;
|
|
519
479
|
private extractErrorMessage;
|
|
520
480
|
private extractErrorTrace;
|
|
521
481
|
}
|
|
@@ -534,46 +494,39 @@ interface LoggerModuleOptions {
|
|
|
534
494
|
exclude?: ExcludeOption[];
|
|
535
495
|
logRequests?: boolean;
|
|
536
496
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
497
|
+
declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<LoggerModuleOptions, "forRoot", "create", {
|
|
498
|
+
global: boolean;
|
|
499
|
+
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: LoggerModuleOptions & Partial<{
|
|
500
|
+
global: boolean;
|
|
501
|
+
}>, ASYNC_OPTIONS_TYPE: _nestjs_common0.ConfigurableModuleAsyncOptions<LoggerModuleOptions, "create"> & Partial<{
|
|
502
|
+
global: boolean;
|
|
503
|
+
}>;
|
|
504
|
+
declare class LoggerModule extends ConfigurableModuleClass implements NestModule {
|
|
505
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
506
|
+
static forRoot(options?: typeof OPTIONS_TYPE): DynamicModule;
|
|
507
|
+
static forRootAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
|
|
508
|
+
private static readonly BASE_EXPORTS;
|
|
509
|
+
private static createConfigProvider;
|
|
546
510
|
private static createCoreProviders;
|
|
547
511
|
private static createDynamicContextProviders;
|
|
548
512
|
}
|
|
549
513
|
//#endregion
|
|
550
|
-
//#region src/
|
|
551
|
-
declare class
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region src/factories/dynamic-context-logger.factory.d.ts
|
|
569
|
-
declare class DynamicContextLoggerFactory {
|
|
570
|
-
private readonly config;
|
|
571
|
-
private readonly formatterFactory;
|
|
572
|
-
private readonly writer;
|
|
573
|
-
private readonly contextResolver;
|
|
574
|
-
private readonly loggerCache;
|
|
575
|
-
constructor(config: LoggerConfiguration, formatterFactory: FormatterFactory, writer: ConsoleWriter, contextResolver: ContextResolver);
|
|
576
|
-
createLogger(context: string): LoggerService;
|
|
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;
|
|
577
530
|
}
|
|
578
531
|
//#endregion
|
|
579
532
|
//#region src/constants/index.d.ts
|
|
@@ -582,18 +535,9 @@ declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
|
582
535
|
declare const LOGGER_EXCLUDE_METADATA: unique symbol;
|
|
583
536
|
//#endregion
|
|
584
537
|
//#region src/decorators/index.d.ts
|
|
585
|
-
/**
|
|
586
|
-
* Decorator to set logging context for a class or method
|
|
587
|
-
*/
|
|
588
538
|
declare const LogContext: (context: string) => _nestjs_common0.CustomDecorator<typeof LOGGER_CONTEXT_METADATA>;
|
|
589
|
-
/**
|
|
590
|
-
* Decorator to add metadata to logs
|
|
591
|
-
*/
|
|
592
539
|
declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common0.CustomDecorator<typeof LOGGER_METADATA_METADATA>;
|
|
593
|
-
/**
|
|
594
|
-
* Decorator to exclude logging for a controller or method
|
|
595
|
-
*/
|
|
596
540
|
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
597
541
|
//#endregion
|
|
598
|
-
export {
|
|
542
|
+
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService, TraceContextService };
|
|
599
543
|
//# sourceMappingURL=index.d.mts.map
|