@globalart/nestjs-logger 1.4.1 → 2.3.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 +144 -430
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -82
- package/dist/index.d.mts +21 -82
- package/dist/index.mjs +130 -408
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -11
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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
|
+
import { ClsService } from "nestjs-cls";
|
|
6
7
|
|
|
7
8
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/types/internal/Subscription.d.ts
|
|
8
9
|
/**
|
|
@@ -352,12 +353,10 @@ declare class Observable<T> implements Subscribable<T> {
|
|
|
352
353
|
}
|
|
353
354
|
//#endregion
|
|
354
355
|
//#region src/types/index.d.ts
|
|
355
|
-
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
356
|
+
type LogLevel$1 = "error" | "warn" | "info" | "debug" | "verbose";
|
|
356
357
|
type LogFormat = "json" | "text" | "pino";
|
|
357
|
-
declare const LOG_LEVELS: Record<LogLevel, number>;
|
|
358
|
-
declare const PINO_LEVELS: Record<number, string>;
|
|
359
358
|
interface LogEntry {
|
|
360
|
-
readonly level: LogLevel;
|
|
359
|
+
readonly level: LogLevel$1;
|
|
361
360
|
readonly message: string;
|
|
362
361
|
readonly timestamp: Date;
|
|
363
362
|
readonly context?: string;
|
|
@@ -406,7 +405,7 @@ interface ExcludeOption {
|
|
|
406
405
|
path: string;
|
|
407
406
|
}
|
|
408
407
|
interface LoggerConfiguration {
|
|
409
|
-
readonly level: LogLevel;
|
|
408
|
+
readonly level: LogLevel$1;
|
|
410
409
|
readonly timestamp: boolean;
|
|
411
410
|
readonly colors: boolean;
|
|
412
411
|
readonly context?: string;
|
|
@@ -415,39 +414,6 @@ interface LoggerConfiguration {
|
|
|
415
414
|
readonly exclude: readonly ExcludeOption[];
|
|
416
415
|
readonly logRequests?: boolean;
|
|
417
416
|
}
|
|
418
|
-
interface FormatterOptions {
|
|
419
|
-
readonly colors: boolean;
|
|
420
|
-
readonly timestamp: boolean;
|
|
421
|
-
readonly context?: string;
|
|
422
|
-
}
|
|
423
|
-
interface LoggerOptions {
|
|
424
|
-
level?: LogLevel;
|
|
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
417
|
//#endregion
|
|
452
418
|
//#region src/contracts/index.d.ts
|
|
453
419
|
interface ILogger {
|
|
@@ -462,8 +428,9 @@ interface ILogFormatter {
|
|
|
462
428
|
format(entry: LogEntry): string;
|
|
463
429
|
formatHttpRequest(entry: HttpRequestLogEntry): string;
|
|
464
430
|
}
|
|
431
|
+
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
465
432
|
interface ILogWriter {
|
|
466
|
-
write(formattedLog: string): void;
|
|
433
|
+
write(formattedLog: string, level?: LogLevel): void;
|
|
467
434
|
}
|
|
468
435
|
interface IContextResolver {
|
|
469
436
|
resolve(): string;
|
|
@@ -481,8 +448,9 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
481
448
|
private readonly formatter;
|
|
482
449
|
private readonly writer;
|
|
483
450
|
private readonly contextResolver;
|
|
451
|
+
private readonly clsService;
|
|
484
452
|
private context?;
|
|
485
|
-
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver);
|
|
453
|
+
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver, clsService: ClsService);
|
|
486
454
|
setContext(context: string): void;
|
|
487
455
|
log(options: LogOptions): void;
|
|
488
456
|
error(options: LogOptions): void;
|
|
@@ -492,7 +460,6 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
492
460
|
logHttpRequest(entry: HttpRequestLogEntry): void;
|
|
493
461
|
private writeLog;
|
|
494
462
|
private resolveTraceIds;
|
|
495
|
-
private enrichWithTraceIds;
|
|
496
463
|
}
|
|
497
464
|
//#endregion
|
|
498
465
|
//#region src/core/http-logger.interceptor.d.ts
|
|
@@ -506,7 +473,6 @@ declare class HttpLoggerInterceptor implements NestInterceptor {
|
|
|
506
473
|
private readonly pid;
|
|
507
474
|
constructor(logger: LoggerService, dataSanitizer: IDataSanitizer, requestIdGenerator: IRequestIdGenerator, config: LoggerConfiguration, reflector: Reflector);
|
|
508
475
|
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
509
|
-
private handleGraphQLRequest;
|
|
510
476
|
private createHttpLogEntry;
|
|
511
477
|
private createLogEntry;
|
|
512
478
|
private getClientIp;
|
|
@@ -533,48 +499,21 @@ interface LoggerModuleOptions {
|
|
|
533
499
|
exclude?: ExcludeOption[];
|
|
534
500
|
logRequests?: boolean;
|
|
535
501
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
502
|
+
declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<LoggerModuleOptions, "forRoot", "create", {
|
|
503
|
+
global: boolean;
|
|
504
|
+
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: LoggerModuleOptions & Partial<{
|
|
505
|
+
global: boolean;
|
|
506
|
+
}>, ASYNC_OPTIONS_TYPE: _nestjs_common0.ConfigurableModuleAsyncOptions<LoggerModuleOptions, "create"> & Partial<{
|
|
507
|
+
global: boolean;
|
|
508
|
+
}>;
|
|
509
|
+
declare class LoggerModule extends ConfigurableModuleClass implements NestModule {
|
|
510
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
511
|
+
static forRoot(options?: typeof OPTIONS_TYPE): DynamicModule;
|
|
512
|
+
static forRootAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
|
|
545
513
|
private static createCoreProviders;
|
|
546
514
|
private static createDynamicContextProviders;
|
|
547
515
|
}
|
|
548
516
|
//#endregion
|
|
549
|
-
//#region src/utils/context-resolver.d.ts
|
|
550
|
-
declare class ContextResolver implements IContextResolver {
|
|
551
|
-
resolve(): string;
|
|
552
|
-
private shouldSkipLine;
|
|
553
|
-
private extractClassName;
|
|
554
|
-
private isValidClassName;
|
|
555
|
-
}
|
|
556
|
-
//#endregion
|
|
557
|
-
//#region src/writers/console-writer.d.ts
|
|
558
|
-
declare class ConsoleWriter implements ILogWriter {
|
|
559
|
-
write(formattedLog: string): void;
|
|
560
|
-
}
|
|
561
|
-
//#endregion
|
|
562
|
-
//#region src/factories/formatter.factory.d.ts
|
|
563
|
-
declare class FormatterFactory {
|
|
564
|
-
create(format: LogFormat, options: FormatterOptions): ILogFormatter;
|
|
565
|
-
}
|
|
566
|
-
//#endregion
|
|
567
|
-
//#region src/factories/dynamic-context-logger.factory.d.ts
|
|
568
|
-
declare class DynamicContextLoggerFactory {
|
|
569
|
-
private readonly config;
|
|
570
|
-
private readonly formatterFactory;
|
|
571
|
-
private readonly writer;
|
|
572
|
-
private readonly contextResolver;
|
|
573
|
-
private readonly loggerCache;
|
|
574
|
-
constructor(config: LoggerConfiguration, formatterFactory: FormatterFactory, writer: ConsoleWriter, contextResolver: ContextResolver);
|
|
575
|
-
createLogger(context: string): LoggerService;
|
|
576
|
-
}
|
|
577
|
-
//#endregion
|
|
578
517
|
//#region src/constants/index.d.ts
|
|
579
518
|
declare const LOGGER_CONTEXT_METADATA: unique symbol;
|
|
580
519
|
declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
@@ -594,5 +533,5 @@ declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common
|
|
|
594
533
|
*/
|
|
595
534
|
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
596
535
|
//#endregion
|
|
597
|
-
export {
|
|
536
|
+
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService };
|
|
598
537
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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
|
+
import { ClsService } from "nestjs-cls";
|
|
6
7
|
|
|
7
8
|
//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/types/internal/Subscription.d.ts
|
|
8
9
|
/**
|
|
@@ -352,12 +353,10 @@ declare class Observable<T> implements Subscribable<T> {
|
|
|
352
353
|
}
|
|
353
354
|
//#endregion
|
|
354
355
|
//#region src/types/index.d.ts
|
|
355
|
-
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
356
|
+
type LogLevel$1 = "error" | "warn" | "info" | "debug" | "verbose";
|
|
356
357
|
type LogFormat = "json" | "text" | "pino";
|
|
357
|
-
declare const LOG_LEVELS: Record<LogLevel, number>;
|
|
358
|
-
declare const PINO_LEVELS: Record<number, string>;
|
|
359
358
|
interface LogEntry {
|
|
360
|
-
readonly level: LogLevel;
|
|
359
|
+
readonly level: LogLevel$1;
|
|
361
360
|
readonly message: string;
|
|
362
361
|
readonly timestamp: Date;
|
|
363
362
|
readonly context?: string;
|
|
@@ -406,7 +405,7 @@ interface ExcludeOption {
|
|
|
406
405
|
path: string;
|
|
407
406
|
}
|
|
408
407
|
interface LoggerConfiguration {
|
|
409
|
-
readonly level: LogLevel;
|
|
408
|
+
readonly level: LogLevel$1;
|
|
410
409
|
readonly timestamp: boolean;
|
|
411
410
|
readonly colors: boolean;
|
|
412
411
|
readonly context?: string;
|
|
@@ -415,39 +414,6 @@ interface LoggerConfiguration {
|
|
|
415
414
|
readonly exclude: readonly ExcludeOption[];
|
|
416
415
|
readonly logRequests?: boolean;
|
|
417
416
|
}
|
|
418
|
-
interface FormatterOptions {
|
|
419
|
-
readonly colors: boolean;
|
|
420
|
-
readonly timestamp: boolean;
|
|
421
|
-
readonly context?: string;
|
|
422
|
-
}
|
|
423
|
-
interface LoggerOptions {
|
|
424
|
-
level?: LogLevel;
|
|
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
417
|
//#endregion
|
|
452
418
|
//#region src/contracts/index.d.ts
|
|
453
419
|
interface ILogger {
|
|
@@ -462,8 +428,9 @@ interface ILogFormatter {
|
|
|
462
428
|
format(entry: LogEntry): string;
|
|
463
429
|
formatHttpRequest(entry: HttpRequestLogEntry): string;
|
|
464
430
|
}
|
|
431
|
+
type LogLevel = "error" | "warn" | "info" | "debug" | "verbose";
|
|
465
432
|
interface ILogWriter {
|
|
466
|
-
write(formattedLog: string): void;
|
|
433
|
+
write(formattedLog: string, level?: LogLevel): void;
|
|
467
434
|
}
|
|
468
435
|
interface IContextResolver {
|
|
469
436
|
resolve(): string;
|
|
@@ -481,8 +448,9 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
481
448
|
private readonly formatter;
|
|
482
449
|
private readonly writer;
|
|
483
450
|
private readonly contextResolver;
|
|
451
|
+
private readonly clsService;
|
|
484
452
|
private context?;
|
|
485
|
-
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver);
|
|
453
|
+
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver, clsService: ClsService);
|
|
486
454
|
setContext(context: string): void;
|
|
487
455
|
log(options: LogOptions): void;
|
|
488
456
|
error(options: LogOptions): void;
|
|
@@ -492,7 +460,6 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
492
460
|
logHttpRequest(entry: HttpRequestLogEntry): void;
|
|
493
461
|
private writeLog;
|
|
494
462
|
private resolveTraceIds;
|
|
495
|
-
private enrichWithTraceIds;
|
|
496
463
|
}
|
|
497
464
|
//#endregion
|
|
498
465
|
//#region src/core/http-logger.interceptor.d.ts
|
|
@@ -506,7 +473,6 @@ declare class HttpLoggerInterceptor implements NestInterceptor {
|
|
|
506
473
|
private readonly pid;
|
|
507
474
|
constructor(logger: LoggerService, dataSanitizer: IDataSanitizer, requestIdGenerator: IRequestIdGenerator, config: LoggerConfiguration, reflector: Reflector);
|
|
508
475
|
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
509
|
-
private handleGraphQLRequest;
|
|
510
476
|
private createHttpLogEntry;
|
|
511
477
|
private createLogEntry;
|
|
512
478
|
private getClientIp;
|
|
@@ -533,48 +499,21 @@ interface LoggerModuleOptions {
|
|
|
533
499
|
exclude?: ExcludeOption[];
|
|
534
500
|
logRequests?: boolean;
|
|
535
501
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
502
|
+
declare const ConfigurableModuleClass: _nestjs_common0.ConfigurableModuleCls<LoggerModuleOptions, "forRoot", "create", {
|
|
503
|
+
global: boolean;
|
|
504
|
+
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: LoggerModuleOptions & Partial<{
|
|
505
|
+
global: boolean;
|
|
506
|
+
}>, ASYNC_OPTIONS_TYPE: _nestjs_common0.ConfigurableModuleAsyncOptions<LoggerModuleOptions, "create"> & Partial<{
|
|
507
|
+
global: boolean;
|
|
508
|
+
}>;
|
|
509
|
+
declare class LoggerModule extends ConfigurableModuleClass implements NestModule {
|
|
510
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
511
|
+
static forRoot(options?: typeof OPTIONS_TYPE): DynamicModule;
|
|
512
|
+
static forRootAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
|
|
545
513
|
private static createCoreProviders;
|
|
546
514
|
private static createDynamicContextProviders;
|
|
547
515
|
}
|
|
548
516
|
//#endregion
|
|
549
|
-
//#region src/utils/context-resolver.d.ts
|
|
550
|
-
declare class ContextResolver implements IContextResolver {
|
|
551
|
-
resolve(): string;
|
|
552
|
-
private shouldSkipLine;
|
|
553
|
-
private extractClassName;
|
|
554
|
-
private isValidClassName;
|
|
555
|
-
}
|
|
556
|
-
//#endregion
|
|
557
|
-
//#region src/writers/console-writer.d.ts
|
|
558
|
-
declare class ConsoleWriter implements ILogWriter {
|
|
559
|
-
write(formattedLog: string): void;
|
|
560
|
-
}
|
|
561
|
-
//#endregion
|
|
562
|
-
//#region src/factories/formatter.factory.d.ts
|
|
563
|
-
declare class FormatterFactory {
|
|
564
|
-
create(format: LogFormat, options: FormatterOptions): ILogFormatter;
|
|
565
|
-
}
|
|
566
|
-
//#endregion
|
|
567
|
-
//#region src/factories/dynamic-context-logger.factory.d.ts
|
|
568
|
-
declare class DynamicContextLoggerFactory {
|
|
569
|
-
private readonly config;
|
|
570
|
-
private readonly formatterFactory;
|
|
571
|
-
private readonly writer;
|
|
572
|
-
private readonly contextResolver;
|
|
573
|
-
private readonly loggerCache;
|
|
574
|
-
constructor(config: LoggerConfiguration, formatterFactory: FormatterFactory, writer: ConsoleWriter, contextResolver: ContextResolver);
|
|
575
|
-
createLogger(context: string): LoggerService;
|
|
576
|
-
}
|
|
577
|
-
//#endregion
|
|
578
517
|
//#region src/constants/index.d.ts
|
|
579
518
|
declare const LOGGER_CONTEXT_METADATA: unique symbol;
|
|
580
519
|
declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
@@ -594,5 +533,5 @@ declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common
|
|
|
594
533
|
*/
|
|
595
534
|
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
596
535
|
//#endregion
|
|
597
|
-
export {
|
|
536
|
+
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService };
|
|
598
537
|
//# sourceMappingURL=index.d.mts.map
|