From a8b000d34730685727e6446b45877667afc53f96 Mon Sep 17 00:00:00 2001 From: sbriat Date: Tue, 4 Apr 2023 09:58:17 +0200 Subject: [PATCH] add health log for services --- src/modules/logger.module.ts | 12 ++++++++++++ .../adapters/primaries/admin-api.controller.ts | 1 - .../logger/adapters/primaries/auth.controller.ts | 10 ++++++++++ .../adapters/primaries/configuration.controller.ts | 10 ++++++++++ .../adapters/primaries/territory.controller.ts | 10 ++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/modules/logger.module.ts b/src/modules/logger.module.ts index ceea287..75d8d67 100644 --- a/src/modules/logger.module.ts +++ b/src/modules/logger.module.ts @@ -54,6 +54,10 @@ import { AdminApiController } from './logger/adapters/primaries/admin-api.contro exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'logging.auth.username.update.warning', }, + loggingAuthHealthCrit: { + exchange: configService.get('RMQ_EXCHANGE'), + routingKey: 'logging.auth.health.crit', + }, loggingConfigurationCreateInfo: { exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'logging.configuration.create.info', @@ -86,6 +90,10 @@ import { AdminApiController } from './logger/adapters/primaries/admin-api.contro exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'logging.configuration.update.crit', }, + loggingConfigurationHealthCrit: { + exchange: configService.get('RMQ_EXCHANGE'), + routingKey: 'logging.configuration.health.crit', + }, loggingTerritoryCreateInfo: { exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'logging.territory.create.info', @@ -118,6 +126,10 @@ import { AdminApiController } from './logger/adapters/primaries/admin-api.contro exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'logging.territory.update.crit', }, + loggingTerritoryHealthCrit: { + exchange: configService.get('RMQ_EXCHANGE'), + routingKey: 'logging.territory.health.crit', + }, loggingUserCreateInfo: { exchange: configService.get('RMQ_EXCHANGE'), routingKey: 'logging.user.create.info', diff --git a/src/modules/logger/adapters/primaries/admin-api.controller.ts b/src/modules/logger/adapters/primaries/admin-api.controller.ts index af88431..1dad810 100644 --- a/src/modules/logger/adapters/primaries/admin-api.controller.ts +++ b/src/modules/logger/adapters/primaries/admin-api.controller.ts @@ -15,7 +15,6 @@ export class AdminApiController { name: 'loggingAdminApiHealthCrit', }) public async adminApiHealthCriticalHandler(message: string) { - console.log('ici'); this.logger.configure( loggerOptions('admin-api', level.crit, 'crit', 'health'), ); diff --git a/src/modules/logger/adapters/primaries/auth.controller.ts b/src/modules/logger/adapters/primaries/auth.controller.ts index 842a31b..f9823c7 100644 --- a/src/modules/logger/adapters/primaries/auth.controller.ts +++ b/src/modules/logger/adapters/primaries/auth.controller.ts @@ -70,4 +70,14 @@ export class AuthController { ); this.logger.warning(JSON.parse(message)); } + + @RabbitSubscribe({ + name: 'loggingAuthHealthCrit', + }) + public async authHealthCriticalHandler(message: string) { + this.logger.configure( + loggerOptions('auth', level.crit, 'critical', 'health'), + ); + this.logger.crit(JSON.parse(message)); + } } diff --git a/src/modules/logger/adapters/primaries/configuration.controller.ts b/src/modules/logger/adapters/primaries/configuration.controller.ts index 722147a..a48e43b 100644 --- a/src/modules/logger/adapters/primaries/configuration.controller.ts +++ b/src/modules/logger/adapters/primaries/configuration.controller.ts @@ -90,4 +90,14 @@ export class ConfigurationController { ); this.logger.crit(JSON.parse(message)); } + + @RabbitSubscribe({ + name: 'loggingConfigurationHealthCrit', + }) + public async configurationHealthCriticalHandler(message: string) { + this.logger.configure( + loggerOptions('configuration', level.crit, 'critical', 'health'), + ); + this.logger.crit(JSON.parse(message)); + } } diff --git a/src/modules/logger/adapters/primaries/territory.controller.ts b/src/modules/logger/adapters/primaries/territory.controller.ts index ce6ae52..eb1caf3 100644 --- a/src/modules/logger/adapters/primaries/territory.controller.ts +++ b/src/modules/logger/adapters/primaries/territory.controller.ts @@ -90,4 +90,14 @@ export class TerritoryController { ); this.logger.crit(JSON.parse(message)); } + + @RabbitSubscribe({ + name: 'loggingTerritoryHealthCrit', + }) + public async territoryHealthCriticalHandler(message: string) { + this.logger.configure( + loggerOptions('territory', level.crit, 'critical', 'health'), + ); + this.logger.crit(JSON.parse(message)); + } }