add matcher logs

This commit is contained in:
sbriat 2023-04-27 16:12:20 +02:00
parent 221884ab52
commit 260cab1913
2 changed files with 29 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import { ConfigurationController } from './logger/adapters/primaries/configurati
import { TerritoryController } from './logger/adapters/primaries/territory.controller'; import { TerritoryController } from './logger/adapters/primaries/territory.controller';
import { GatewayApiController } from './logger/adapters/primaries/gateway-api.controller'; import { GatewayApiController } from './logger/adapters/primaries/gateway-api.controller';
import { AdminApiController } from './logger/adapters/primaries/admin-api.controller'; import { AdminApiController } from './logger/adapters/primaries/admin-api.controller';
import { MatcherController } from './logger/adapters/primaries/matcher.controller';
@Module({ @Module({
imports: [ imports: [
@ -94,6 +95,10 @@ import { AdminApiController } from './logger/adapters/primaries/admin-api.contro
exchange: configService.get<string>('RMQ_EXCHANGE'), exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.configuration.health.crit', routingKey: 'logging.configuration.health.crit',
}, },
loggingMatcherMatchCrit: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.matcher.match.crit',
},
loggingTerritoryCreateInfo: { loggingTerritoryCreateInfo: {
exchange: configService.get<string>('RMQ_EXCHANGE'), exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.territory.create.info', routingKey: 'logging.territory.create.info',
@ -182,6 +187,7 @@ import { AdminApiController } from './logger/adapters/primaries/admin-api.contro
AuthController, AuthController,
UserController, UserController,
ConfigurationController, ConfigurationController,
MatcherController,
TerritoryController, TerritoryController,
GatewayApiController, GatewayApiController,
AdminApiController, AdminApiController,

View File

@ -0,0 +1,23 @@
import { RabbitSubscribe } from '@golevelup/nestjs-rabbitmq';
import { Controller, Inject } from '@nestjs/common';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
import { level } from './logger/level.enum';
import loggerOptions from './logger/logger';
@Controller()
export class MatcherController {
constructor(
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
) {}
@RabbitSubscribe({
name: 'loggingMatcherMatchCrit',
})
public async matcherMatchCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('matcher', level.crit, 'critical', 'match'),
);
this.logger.crit(JSON.parse(message));
}
}