admin api logs

This commit is contained in:
sbriat 2023-03-31 17:34:47 +02:00
parent ae62b4c4b2
commit 4b6c60da45
2 changed files with 30 additions and 0 deletions

View File

@ -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<string>('RMQ_EXCHANGE'),
routingKey: 'logging.gateway-api.health.crit',
},
loggingAdminApiHealthCrit: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.admin-api.health.crit',
},
loggingAuthCreateCrit: {
exchange: configService.get<string>('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: [],

View File

@ -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));
}
}