98 lines
2.7 KiB
TypeScript
98 lines
2.7 KiB
TypeScript
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 '../level.enum';
|
|
import loggerOptions from '../logger.options';
|
|
|
|
@Controller()
|
|
export class AdController {
|
|
constructor(
|
|
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
|
) {}
|
|
|
|
@RabbitSubscribe({
|
|
name: 'loggingAdCreatedInfo',
|
|
})
|
|
public async adCreatedInfoHandler(message: string) {
|
|
this.logger.configure(loggerOptions('ad', level.info, 'info', 'created'));
|
|
this.logger.info(JSON.parse(message));
|
|
}
|
|
|
|
@RabbitSubscribe({
|
|
name: 'loggingAdCreatedWarning',
|
|
})
|
|
public async adCreatedWarningHandler(message: string) {
|
|
this.logger.configure(
|
|
loggerOptions('ad', level.warning, 'warning', 'created'),
|
|
);
|
|
this.logger.warning(JSON.parse(message));
|
|
}
|
|
|
|
@RabbitSubscribe({
|
|
name: 'loggingAdCreatedCrit',
|
|
})
|
|
public async adCreatedCriticalHandler(message: string) {
|
|
this.logger.configure(
|
|
loggerOptions('ad', level.crit, 'critical', 'created'),
|
|
);
|
|
this.logger.crit(JSON.parse(message));
|
|
}
|
|
|
|
@RabbitSubscribe({
|
|
name: 'loggingAdDeletedInfo',
|
|
})
|
|
public async adDeletedInfoHandler(message: string) {
|
|
this.logger.configure(loggerOptions('ad', level.info, 'info', 'deleted'));
|
|
this.logger.info(JSON.parse(message));
|
|
}
|
|
|
|
@RabbitSubscribe({
|
|
name: 'loggingAdDeletedCrit',
|
|
})
|
|
public async adDeletedCriticalHandler(message: string) {
|
|
this.logger.configure(
|
|
loggerOptions('ad', level.crit, 'critical', 'deleted'),
|
|
);
|
|
this.logger.crit(JSON.parse(message));
|
|
}
|
|
|
|
@RabbitSubscribe({
|
|
name: 'loggingAdReadWarning',
|
|
})
|
|
public async adReadWarningHandler(message: string) {
|
|
this.logger.configure(
|
|
loggerOptions('ad', level.warning, 'warning', 'read'),
|
|
);
|
|
this.logger.warning(JSON.parse(message));
|
|
}
|
|
|
|
@RabbitSubscribe({
|
|
name: 'loggingAdUpdatedInfo',
|
|
})
|
|
public async adUpdatedInfoHandler(message: string) {
|
|
this.logger.configure(loggerOptions('ad', level.info, 'info', 'updated'));
|
|
this.logger.info(JSON.parse(message));
|
|
}
|
|
|
|
@RabbitSubscribe({
|
|
name: 'loggingAdUpdatedCrit',
|
|
})
|
|
public async adUpdatedCriticalHandler(message: string) {
|
|
this.logger.configure(
|
|
loggerOptions('ad', level.crit, 'critical', 'updated'),
|
|
);
|
|
this.logger.crit(JSON.parse(message));
|
|
}
|
|
|
|
@RabbitSubscribe({
|
|
name: 'loggingAdHealthCrit',
|
|
})
|
|
public async adHealthCriticalHandler(message: string) {
|
|
this.logger.configure(
|
|
loggerOptions('ad', level.crit, 'critical', 'health'),
|
|
);
|
|
this.logger.crit(JSON.parse(message));
|
|
}
|
|
}
|