From 23d4d17f1f7cafc31e40660df67ab21b0efa2f9b Mon Sep 17 00:00:00 2001 From: mawahl Date: Tue, 21 Nov 2023 09:12:50 +0100 Subject: [PATCH] introduce low dash separated config vars --- src/core/logging/module-logger.ts | 2 +- src/modules/person/api/person.controller.ts | 10 ++++++++++ src/shared/config/logging.config.ts | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/logging/module-logger.ts b/src/core/logging/module-logger.ts index da8ef8488..b072e2ca8 100644 --- a/src/core/logging/module-logger.ts +++ b/src/core/logging/module-logger.ts @@ -44,7 +44,7 @@ export class ModuleLogger { this.moduleNameInternal = moduleName; const loggerConfig: LoggingConfig = configService.getOrThrow('LOGGING'); - const configKey: keyof LoggingConfig = `${moduleName.toUpperCase()}_LOG_LEVEL` as keyof LoggingConfig; + const configKey: keyof LoggingConfig = `${moduleName.split(/(?=[A-Z])/).join('_').toUpperCase()}_LOG_LEVEL` as keyof LoggingConfig; const level: Option = loggerConfig[configKey] ?? loggerConfig.DEFAULT_LOG_LEVEL; const loggerFormat: winston.Logform.Format = format.combine( format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }), diff --git a/src/modules/person/api/person.controller.ts b/src/modules/person/api/person.controller.ts index 9ef8cb62a..429590a5a 100644 --- a/src/modules/person/api/person.controller.ts +++ b/src/modules/person/api/person.controller.ts @@ -45,12 +45,14 @@ import { PersonenkontextQueryParams } from './personenkontext-query.params.js'; import { PersonenkontextDto } from './personenkontext.dto.js'; import { PersonenkontextResponse } from './personenkontext.response.js'; import { PersonenkontextUc } from './personenkontext.uc.js'; +import { ClassLogger } from '../../../core/logging/class-logger.js'; @ApiTags('personen') @Controller({ path: 'personen' }) @Public() export class PersonController { public constructor( + private readonly logger: ClassLogger, private readonly personUc: PersonUc, private readonly personenkontextUc: PersonenkontextUc, @Inject(getMapperToken()) private readonly mapper: Mapper, @@ -64,6 +66,14 @@ export class PersonController { @ApiForbiddenResponse({ description: 'Insufficient permissions to create the person.' }) @ApiInternalServerErrorResponse({ description: 'Internal server error while creating the person.' }) public async createPerson(@Body() params: CreatePersonBodyParams): Promise { + this.logger.emerg('This is an emerg message'); + this.logger.alert('this is an alert message'); + this.logger.crit('this is a crit message'); + this.logger.error('this is an error message'); + this.logger.warning('this is a warning message'); + this.logger.notice('this is a notice message'); + this.logger.info('this is an info message'); + this.logger.debug('this is a debug message'); const dto: CreatePersonDto = this.mapper.map(params, CreatePersonBodyParams, CreatePersonDto); const person: PersonDto = await this.personUc.createPerson(dto); const personendatensatzDto: PersonendatensatzDto = { diff --git a/src/shared/config/logging.config.ts b/src/shared/config/logging.config.ts index 3d0591661..4dafbaee4 100644 --- a/src/shared/config/logging.config.ts +++ b/src/shared/config/logging.config.ts @@ -15,7 +15,7 @@ export class LoggingConfig { //API Modules - public readonly PERSONAPIMODULE_LOG_LEVEL?: string; + public readonly PERSON_API_MODULE_LOG_LEVEL!: string; public readonly ORGANISATIONAPIMODULE_LOG_LEVEL?: string;