diff --git a/src/message-dispatcher.interceptor.ts b/src/message-dispatcher.interceptor.ts index 5e5cd9e..6aac12e 100644 --- a/src/message-dispatcher.interceptor.ts +++ b/src/message-dispatcher.interceptor.ts @@ -3,6 +3,7 @@ import { ExecutionContext, Inject, Injectable, + Logger, NestInterceptor, } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; @@ -17,6 +18,8 @@ import { Options } from './options.dto'; @Injectable() export class MessageDispatcherInterceptor implements NestInterceptor { + logger = new Logger(MessageDispatcherInterceptor.name); + constructor( @Inject(AsyncLoggerProvider) private client: AsyncLoggerProvider, private options: Options, @@ -57,6 +60,10 @@ export class MessageDispatcherInterceptor implements NestInterceptor { timestamp: timestamp(), }; + if (this.options.debug) { + this.logger.debug(this.options.subject, JSON.stringify(sendData)); + } + await this.client.log(this.options.subject, sendData); } }), diff --git a/src/options.dto.ts b/src/options.dto.ts index 6b0a0a5..c20acc0 100644 --- a/src/options.dto.ts +++ b/src/options.dto.ts @@ -3,4 +3,5 @@ import { Message } from './message.dto'; export class Options { subject: string; messageData: Message; + debug?: boolean; }