Merge branch 'addConfigurationLog' into 'main'
add auth and configuration logs See merge request v3/services/logger!3
This commit is contained in:
commit
2ca877419f
|
@ -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",
|
"version": "0.0.1",
|
||||||
"description": "Mobicoop V3 Logger Service",
|
"description": "Mobicoop V3 Logger Service",
|
||||||
"author": "sbriat",
|
"author": "sbriat",
|
||||||
|
|
|
@ -4,6 +4,8 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||||
import { UserController } from './logger/adapters/primaries/user.controller';
|
import { UserController } from './logger/adapters/primaries/user.controller';
|
||||||
import { WinstonModule } from 'nest-winston';
|
import { WinstonModule } from 'nest-winston';
|
||||||
import * as winston from 'winston';
|
import * as winston from 'winston';
|
||||||
|
import { AuthController } from './logger/adapters/primaries/auth.controller';
|
||||||
|
import { ConfigurationController } from './logger/adapters/primaries/configuration.controller';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -26,7 +28,7 @@ import * as winston from 'winston';
|
||||||
transports: [],
|
transports: [],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
controllers: [UserController],
|
controllers: [AuthController, UserController, ConfigurationController],
|
||||||
providers: [],
|
providers: [],
|
||||||
exports: [],
|
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