diff --git a/src/modules/logger.module.ts b/src/modules/logger.module.ts index dddcbc1..c57df59 100644 --- a/src/modules/logger.module.ts +++ b/src/modules/logger.module.ts @@ -8,6 +8,7 @@ import { AuthController } from './logger/adapters/primaries/auth.controller'; import { ConfigurationController } from './logger/adapters/primaries/configuration.controller'; import { TerritoryController } from './logger/adapters/primaries/territory.controller'; import { GatewayApiController } from './logger/adapters/primaries/gateway-api.controller'; +import { AdminApiController } from './logger/adapters/primaries/admin-api.controller'; @Module({ imports: [ @@ -25,6 +26,10 @@ import { GatewayApiController } from './logger/adapters/primaries/gateway-api.co exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'logging.gateway-api.health.crit', }, + loggingAdminApiHealthCrit: { + exchange: configService.get('RMQ_EXCHANGE'), + routingKey: 'logging.admin-api.health.crit', + }, loggingAuthCreateCrit: { exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'logging.auth.create.crit', @@ -163,6 +168,7 @@ import { GatewayApiController } from './logger/adapters/primaries/gateway-api.co ConfigurationController, TerritoryController, GatewayApiController, + AdminApiController, ], providers: [], exports: [], diff --git a/src/modules/logger/adapters/primaries/admin-api.controller.ts b/src/modules/logger/adapters/primaries/admin-api.controller.ts new file mode 100644 index 0000000..af88431 --- /dev/null +++ b/src/modules/logger/adapters/primaries/admin-api.controller.ts @@ -0,0 +1,24 @@ +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 AdminApiController { + constructor( + @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger, + ) {} + + @RabbitSubscribe({ + name: 'loggingAdminApiHealthCrit', + }) + public async adminApiHealthCriticalHandler(message: string) { + console.log('ici'); + this.logger.configure( + loggerOptions('admin-api', level.crit, 'crit', 'health'), + ); + this.logger.crit(JSON.parse(message)); + } +}