Merge branch 'gatewayLog' into 'main'

gateway api logs

See merge request v3/service/logger!12
This commit is contained in:
Sylvain Briat 2023-03-31 14:02:09 +00:00
commit ae62b4c4b2
3 changed files with 30 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import * as winston from 'winston';
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';
@Module({
imports: [
@ -20,6 +21,10 @@ import { TerritoryController } from './logger/adapters/primaries/territory.contr
},
],
handlers: {
loggingGatewayApiHealthCrit: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.gateway-api.health.crit',
},
loggingAuthCreateCrit: {
exchange: configService.get<string>('RMQ_EXCHANGE'),
routingKey: 'logging.auth.create.crit',
@ -157,6 +162,7 @@ import { TerritoryController } from './logger/adapters/primaries/territory.contr
UserController,
ConfigurationController,
TerritoryController,
GatewayApiController,
],
providers: [],
exports: [],

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 GatewayApiController {
constructor(
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
) {}
@RabbitSubscribe({
name: 'loggingGatewayApiHealthCrit',
})
public async gatewayApiHealthCriticalHandler(message: string) {
this.logger.configure(
loggerOptions('gateway-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 = '.log';
extension = '.json';
maxSize = '1m';
maxFiles = '60';
zippedArchive = true;