Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use the Logger passed in RabbitMQModule config instead of default #663

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/rabbitmq/src/rabbitmq.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
Logger,
OnApplicationBootstrap,
OnApplicationShutdown,
Inject,
LoggerService,
} from '@nestjs/common';
import { ROUTE_ARGS_METADATA } from '@nestjs/common/constants';
import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator';
Expand Down Expand Up @@ -61,7 +63,7 @@ export class RabbitMQModule
)
implements OnApplicationBootstrap, OnApplicationShutdown
{
private readonly logger = new Logger(RabbitMQModule.name);
private readonly logger: LoggerService;

private static connectionManager = new AmqpConnectionManager();
private static bootstrapped = false;
Expand All @@ -70,9 +72,11 @@ export class RabbitMQModule
private readonly discover: DiscoveryService,
private readonly externalContextCreator: ExternalContextCreator,
private readonly rpcParamsFactory: RabbitRpcParamsFactory,
private readonly connectionManager: AmqpConnectionManager
private readonly connectionManager: AmqpConnectionManager,
@Inject(RABBIT_CONFIG_TOKEN) config: RabbitMQConfig
) {
super();
this.logger = config.logger || new Logger(RabbitMQModule.name);
}

static async AmqpConnectionFactory(config: RabbitMQConfig) {
Expand Down Expand Up @@ -119,7 +123,7 @@ export class RabbitMQModule
}

async onApplicationShutdown() {
this.logger.verbose('Closing AMQP Connections');
this.logger.verbose?.('Closing AMQP Connections');

await Promise.all(
this.connectionManager
Expand Down
Loading