mirror of
https://gitlab.com/mobicoop/v3/service/logger.git
synced 2026-01-10 15:02:38 +00:00
complete user and auth services logs
This commit is contained in:
73
src/modules/logger/adapters/primaries/auth.controller.ts
Normal file
73
src/modules/logger/adapters/primaries/auth.controller.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
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 AuthController {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'auth.create.crit',
|
||||
queue: 'logging-auth-create-crit',
|
||||
})
|
||||
public async authCreatedCriticalHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.crit, 'critical'));
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'auth.delete.crit',
|
||||
queue: 'logging-auth-delete-crit',
|
||||
})
|
||||
public async authDeletedCriticalHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.crit, 'critical'));
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'auth.username.add.warning',
|
||||
queue: 'logging-auth-username-add-warning',
|
||||
})
|
||||
public async authUsernameAddedWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.warning, 'warning'));
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'auth.username.delete.warning',
|
||||
queue: 'logging-auth-username-delete-warning',
|
||||
})
|
||||
public async authUsernameDeletedWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.warning, 'warning'));
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'auth.password.update.warning',
|
||||
queue: 'logging-auth-password-update-warning',
|
||||
})
|
||||
public async authPasswordUpdatedWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.warning, 'warning'));
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'auth.username.update.warning',
|
||||
queue: 'logging-auth-username-update-warning',
|
||||
})
|
||||
public async authUsernameUpdatedWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('auth', level.warning, 'warning'));
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
}
|
||||
@@ -40,4 +40,54 @@ export class UserController {
|
||||
this.logger.configure(loggerOptions('user', level.crit, 'critical'));
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'user.delete.info',
|
||||
queue: 'logging-user-delete-info',
|
||||
})
|
||||
public async userDeletedInfoHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.info, 'info'));
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'user.delete.crit',
|
||||
queue: 'logging-user-delete-crit',
|
||||
})
|
||||
public async userDeletedCriticalHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.crit, 'critical'));
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'user.read.warning',
|
||||
queue: 'logging-user-read-warning',
|
||||
})
|
||||
public async userReadWarningHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.warning, 'warning'));
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'user.update.info',
|
||||
queue: 'logging-user-update-info',
|
||||
})
|
||||
public async userUpdatedInfoHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.info, 'info'));
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'user.update.crit',
|
||||
queue: 'logging-user-update-crit',
|
||||
})
|
||||
public async userUpdatedCriticalHandler(message: string) {
|
||||
this.logger.configure(loggerOptions('user', level.crit, 'critical'));
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user