Skip to content

Commit

Permalink
introduce low dash separated config vars
Browse files Browse the repository at this point in the history
  • Loading branch information
WahlMartin committed Nov 21, 2023
1 parent a66ab87 commit 23d4d17
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/logging/module-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ModuleLogger {
this.moduleNameInternal = moduleName;

const loggerConfig: LoggingConfig = configService.getOrThrow<LoggingConfig>('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;

Check warning on line 47 in src/core/logging/module-logger.ts

View workflow job for this annotation

GitHub Actions / Linting / Nest Lint

Replace `.split(/(?=[A-Z])/).join('_')` with `⏎············.split(/(?=[A-Z])/)⏎············.join('_')⏎············`
const level: Option<string> = loggerConfig[configKey] ?? loggerConfig.DEFAULT_LOG_LEVEL;
const loggerFormat: winston.Logform.Format = format.combine(
format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }),
Expand Down
10 changes: 10 additions & 0 deletions src/modules/person/api/person.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<PersonendatensatzResponse> {
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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/config/logging.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 23d4d17

Please sign in to comment.