add auth and configuration logs
This commit is contained in:
parent
11c2154cd8
commit
25041325a2
|
@ -0,0 +1,24 @@
|
|||
image: docker:20.10.22
|
||||
|
||||
stages:
|
||||
- build
|
||||
|
||||
###############
|
||||
# BUILD STAGE #
|
||||
###############
|
||||
|
||||
build:
|
||||
stage: build
|
||||
image: docker:20.10.22
|
||||
variables:
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
services:
|
||||
- docker:dind
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
script:
|
||||
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
|
||||
- docker push "$CI_REGISTRY_IMAGE"
|
||||
only:
|
||||
- main
|
||||
when: manual
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "mobicoop-v3-logger",
|
||||
"name": "@mobicoop/logger",
|
||||
"version": "0.0.1",
|
||||
"description": "Mobicoop V3 Logger Service",
|
||||
"author": "sbriat",
|
||||
|
|
|
@ -4,6 +4,8 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
|
|||
import { UserController } from './logger/adapters/primaries/user.controller';
|
||||
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';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -26,7 +28,7 @@ import * as winston from 'winston';
|
|||
transports: [],
|
||||
}),
|
||||
],
|
||||
controllers: [UserController],
|
||||
controllers: [AuthController, UserController, ConfigurationController],
|
||||
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 ConfigurationController {
|
||||
constructor(
|
||||
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'configuration.create.info',
|
||||
queue: 'logging-configuration-create-info',
|
||||
})
|
||||
public async configurationCreatedInfoHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('configuration', level.info, 'info', 'create'),
|
||||
);
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'configuration.create.warning',
|
||||
queue: 'logging-configuration-create-warning',
|
||||
})
|
||||
public async configurationCreatedWarningHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('configuration', level.warning, 'warning', 'create'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'configuration.create.crit',
|
||||
queue: 'logging-configuration-create-crit',
|
||||
})
|
||||
public async configurationCreatedCriticalHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('configuration', level.crit, 'critical', 'create'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'configuration.delete.info',
|
||||
queue: 'logging-configuration-delete-info',
|
||||
})
|
||||
public async configurationDeletedInfoHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('configuration', level.info, 'info', 'delete'),
|
||||
);
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'configuration.delete.crit',
|
||||
queue: 'logging-configuration-delete-crit',
|
||||
})
|
||||
public async configurationDeletedCriticalHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('configuration', level.crit, 'critical', 'delete'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'configuration.read.warning',
|
||||
queue: 'logging-configuration-read-warning',
|
||||
})
|
||||
public async configurationReadWarningHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('configuration', level.warning, 'warning', 'read'),
|
||||
);
|
||||
this.logger.warning(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'configuration.update.info',
|
||||
queue: 'logging-configuration-update-info',
|
||||
})
|
||||
public async configurationUpdatedInfoHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('configuration', level.info, 'info', 'update'),
|
||||
);
|
||||
this.logger.info(JSON.parse(message));
|
||||
}
|
||||
|
||||
@RabbitSubscribe({
|
||||
exchange: 'logging',
|
||||
routingKey: 'configuration.update.crit',
|
||||
queue: 'logging-configuration-update-crit',
|
||||
})
|
||||
public async configurationUpdatedCriticalHandler(message: string) {
|
||||
this.logger.configure(
|
||||
loggerOptions('configuration', level.crit, 'critical', 'update'),
|
||||
);
|
||||
this.logger.crit(JSON.parse(message));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue