@globalart/nestjs-logger 1.4.2 → 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 +124 -426
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -78
- package/dist/index.d.mts +16 -78
- package/dist/index.mjs +110 -404
- 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
|
/**
|
|
@@ -354,8 +355,6 @@ declare class Observable<T> implements Subscribable<T> {
|
|
|
354
355
|
//#region src/types/index.d.ts
|
|
355
356
|
type LogLevel$1 = "error" | "warn" | "info" | "debug" | "verbose";
|
|
356
357
|
type LogFormat = "json" | "text" | "pino";
|
|
357
|
-
declare const LOG_LEVELS: Record<LogLevel$1, number>;
|
|
358
|
-
declare const PINO_LEVELS: Record<number, string>;
|
|
359
358
|
interface LogEntry {
|
|
360
359
|
readonly level: LogLevel$1;
|
|
361
360
|
readonly message: 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$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
417
|
//#endregion
|
|
452
418
|
//#region src/contracts/index.d.ts
|
|
453
419
|
interface ILogger {
|
|
@@ -482,8 +448,9 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
482
448
|
private readonly formatter;
|
|
483
449
|
private readonly writer;
|
|
484
450
|
private readonly contextResolver;
|
|
451
|
+
private readonly clsService;
|
|
485
452
|
private context?;
|
|
486
|
-
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver);
|
|
453
|
+
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver, clsService: ClsService);
|
|
487
454
|
setContext(context: string): void;
|
|
488
455
|
log(options: LogOptions): void;
|
|
489
456
|
error(options: LogOptions): void;
|
|
@@ -493,7 +460,6 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
493
460
|
logHttpRequest(entry: HttpRequestLogEntry): void;
|
|
494
461
|
private writeLog;
|
|
495
462
|
private resolveTraceIds;
|
|
496
|
-
private enrichWithTraceIds;
|
|
497
463
|
}
|
|
498
464
|
//#endregion
|
|
499
465
|
//#region src/core/http-logger.interceptor.d.ts
|
|
@@ -507,7 +473,6 @@ declare class HttpLoggerInterceptor implements NestInterceptor {
|
|
|
507
473
|
private readonly pid;
|
|
508
474
|
constructor(logger: LoggerService, dataSanitizer: IDataSanitizer, requestIdGenerator: IRequestIdGenerator, config: LoggerConfiguration, reflector: Reflector);
|
|
509
475
|
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
510
|
-
private handleGraphQLRequest;
|
|
511
476
|
private createHttpLogEntry;
|
|
512
477
|
private createLogEntry;
|
|
513
478
|
private getClientIp;
|
|
@@ -534,48 +499,21 @@ interface LoggerModuleOptions {
|
|
|
534
499
|
exclude?: ExcludeOption[];
|
|
535
500
|
logRequests?: boolean;
|
|
536
501
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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;
|
|
546
513
|
private static createCoreProviders;
|
|
547
514
|
private static createDynamicContextProviders;
|
|
548
515
|
}
|
|
549
516
|
//#endregion
|
|
550
|
-
//#region src/utils/context-resolver.d.ts
|
|
551
|
-
declare class ContextResolver implements IContextResolver {
|
|
552
|
-
resolve(): string;
|
|
553
|
-
private shouldSkipLine;
|
|
554
|
-
private extractClassName;
|
|
555
|
-
private isValidClassName;
|
|
556
|
-
}
|
|
557
|
-
//#endregion
|
|
558
|
-
//#region src/writers/console-writer.d.ts
|
|
559
|
-
declare class ConsoleWriter implements ILogWriter {
|
|
560
|
-
write(formattedLog: string, level?: LogLevel): void;
|
|
561
|
-
}
|
|
562
|
-
//#endregion
|
|
563
|
-
//#region src/factories/formatter.factory.d.ts
|
|
564
|
-
declare class FormatterFactory {
|
|
565
|
-
create(format: LogFormat, options: FormatterOptions): ILogFormatter;
|
|
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;
|
|
577
|
-
}
|
|
578
|
-
//#endregion
|
|
579
517
|
//#region src/constants/index.d.ts
|
|
580
518
|
declare const LOGGER_CONTEXT_METADATA: unique symbol;
|
|
581
519
|
declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
@@ -595,5 +533,5 @@ declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common
|
|
|
595
533
|
*/
|
|
596
534
|
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
597
535
|
//#endregion
|
|
598
|
-
export {
|
|
536
|
+
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService };
|
|
599
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
|
/**
|
|
@@ -354,8 +355,6 @@ declare class Observable<T> implements Subscribable<T> {
|
|
|
354
355
|
//#region src/types/index.d.ts
|
|
355
356
|
type LogLevel$1 = "error" | "warn" | "info" | "debug" | "verbose";
|
|
356
357
|
type LogFormat = "json" | "text" | "pino";
|
|
357
|
-
declare const LOG_LEVELS: Record<LogLevel$1, number>;
|
|
358
|
-
declare const PINO_LEVELS: Record<number, string>;
|
|
359
358
|
interface LogEntry {
|
|
360
359
|
readonly level: LogLevel$1;
|
|
361
360
|
readonly message: 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$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
417
|
//#endregion
|
|
452
418
|
//#region src/contracts/index.d.ts
|
|
453
419
|
interface ILogger {
|
|
@@ -482,8 +448,9 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
482
448
|
private readonly formatter;
|
|
483
449
|
private readonly writer;
|
|
484
450
|
private readonly contextResolver;
|
|
451
|
+
private readonly clsService;
|
|
485
452
|
private context?;
|
|
486
|
-
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver);
|
|
453
|
+
constructor(config: LoggerConfiguration, formatter: ILogFormatter, writer: ILogWriter, contextResolver: IContextResolver, clsService: ClsService);
|
|
487
454
|
setContext(context: string): void;
|
|
488
455
|
log(options: LogOptions): void;
|
|
489
456
|
error(options: LogOptions): void;
|
|
@@ -493,7 +460,6 @@ declare class LoggerService implements LoggerService$1, ILogger {
|
|
|
493
460
|
logHttpRequest(entry: HttpRequestLogEntry): void;
|
|
494
461
|
private writeLog;
|
|
495
462
|
private resolveTraceIds;
|
|
496
|
-
private enrichWithTraceIds;
|
|
497
463
|
}
|
|
498
464
|
//#endregion
|
|
499
465
|
//#region src/core/http-logger.interceptor.d.ts
|
|
@@ -507,7 +473,6 @@ declare class HttpLoggerInterceptor implements NestInterceptor {
|
|
|
507
473
|
private readonly pid;
|
|
508
474
|
constructor(logger: LoggerService, dataSanitizer: IDataSanitizer, requestIdGenerator: IRequestIdGenerator, config: LoggerConfiguration, reflector: Reflector);
|
|
509
475
|
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
510
|
-
private handleGraphQLRequest;
|
|
511
476
|
private createHttpLogEntry;
|
|
512
477
|
private createLogEntry;
|
|
513
478
|
private getClientIp;
|
|
@@ -534,48 +499,21 @@ interface LoggerModuleOptions {
|
|
|
534
499
|
exclude?: ExcludeOption[];
|
|
535
500
|
logRequests?: boolean;
|
|
536
501
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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;
|
|
546
513
|
private static createCoreProviders;
|
|
547
514
|
private static createDynamicContextProviders;
|
|
548
515
|
}
|
|
549
516
|
//#endregion
|
|
550
|
-
//#region src/utils/context-resolver.d.ts
|
|
551
|
-
declare class ContextResolver implements IContextResolver {
|
|
552
|
-
resolve(): string;
|
|
553
|
-
private shouldSkipLine;
|
|
554
|
-
private extractClassName;
|
|
555
|
-
private isValidClassName;
|
|
556
|
-
}
|
|
557
|
-
//#endregion
|
|
558
|
-
//#region src/writers/console-writer.d.ts
|
|
559
|
-
declare class ConsoleWriter implements ILogWriter {
|
|
560
|
-
write(formattedLog: string, level?: LogLevel): void;
|
|
561
|
-
}
|
|
562
|
-
//#endregion
|
|
563
|
-
//#region src/factories/formatter.factory.d.ts
|
|
564
|
-
declare class FormatterFactory {
|
|
565
|
-
create(format: LogFormat, options: FormatterOptions): ILogFormatter;
|
|
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;
|
|
577
|
-
}
|
|
578
|
-
//#endregion
|
|
579
517
|
//#region src/constants/index.d.ts
|
|
580
518
|
declare const LOGGER_CONTEXT_METADATA: unique symbol;
|
|
581
519
|
declare const LOGGER_METADATA_METADATA: unique symbol;
|
|
@@ -595,5 +533,5 @@ declare const LogMetadata: (metadata: Record<string, unknown>) => _nestjs_common
|
|
|
595
533
|
*/
|
|
596
534
|
declare const ExcludeLogging: () => _nestjs_common0.CustomDecorator<typeof LOGGER_EXCLUDE_METADATA>;
|
|
597
535
|
//#endregion
|
|
598
|
-
export {
|
|
536
|
+
export { ExcludeLogging, HttpLoggerInterceptor, InjectLogger, LogContext, LogMetadata, LoggerModule, LoggerService };
|
|
599
537
|
//# sourceMappingURL=index.d.mts.map
|