gateway api logs

This commit is contained in:
sbriat 2023-03-31 16:01:02 +02:00
parent 536cca06c3
commit fb116d4b0e
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;