Skip to content

Commit

Permalink
fix: use the Logger passed in config instead of default (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-gregoire committed Nov 18, 2023
1 parent c3baf7d commit ec69e13
Showing 1 changed file with 7 additions and 3 deletions.
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

0 comments on commit ec69e13

Please sign in to comment.