add territory logs
This commit is contained in:
parent
ac13d968e4
commit
b53bf571fe
|
@ -6,6 +6,7 @@ import { WinstonModule } from 'nest-winston';
|
|||
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';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -28,7 +29,12 @@ import { ConfigurationController } from './logger/adapters/primaries/configurati
|
|||
transports: [],
|
||||
}),
|
||||
],
|
||||
controllers: [AuthController, UserController, ConfigurationController],
|
||||
controllers: [
|
||||
AuthController,
|
||||
UserController,
|
||||
ConfigurationController,
|
||||
TerritoryController,
|
||||
],
|
||||
providers: [],
|
||||
exports: [],
|
||||
})
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
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 TerritoryController {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'territory.create.info',
|
||||
queue: 'logging-territory-create-info',
|
||||
})
|
||||
public async territoryCreatedInfoHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('territory', level.info, 'info', 'create'),
|
||||
);
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'territory.create.warning',
|
||||
queue: 'logging-territory-create-warning',
|
||||
})
|
||||
public async territoryCreatedWarningHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('territory', level.warning, 'warning', 'create'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'territory.create.crit',
|
||||
queue: 'logging-territory-create-crit',
|
||||
})
|
||||
public async territoryCreatedCriticalHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('territory', level.crit, 'critical', 'create'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'territory.delete.info',
|
||||
queue: 'logging-territory-delete-info',
|
||||
})
|
||||
public async territoryDeletedInfoHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('territory', level.info, 'info', 'delete'),
|
||||
);
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'territory.delete.crit',
|
||||
queue: 'logging-territory-delete-crit',
|
||||
})
|
||||
public async territoryDeletedCriticalHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('territory', level.crit, 'critical', 'delete'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'territory.read.warning',
|
||||
queue: 'logging-territory-read-warning',
|
||||
})
|
||||
public async territoryReadWarningHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('territory', level.warning, 'warning', 'read'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'territory.update.info',
|
||||
queue: 'logging-territory-update-info',
|
||||
})
|
||||
public async territoryUpdatedInfoHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('territory', level.info, 'info', 'update'),
|
||||
);
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'territory.update.crit',
|
||||
queue: 'logging-territory-update-crit',
|
||||
})
|
||||
public async territoryUpdatedCriticalHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('territory', level.crit, 'critical', 'update'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue