Merge branch 'adminApiLog' into 'main'

Admin api log

See merge request v3/service/logger!13
This commit is contained in:
Sylvain Briat 2023-03-31 15:42:20 +00:00
commit 7444e46738
3 changed files with 31 additions and 1 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));
}
}

View File

@ -3,7 +3,7 @@ import * as winston from 'winston';
import { level as levelEnum } from './level.enum';
export class TransportOptions {
extension = '.json';
extension = '.log';
maxSize = '1m';
maxFiles = '60';
zippedArchive = true;