@@ -10,6 +10,7 @@ import {
|
||||
validateSync,
|
||||
} from 'class-validator';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { type LoggerOptions } from 'typeorm/logger/LoggerOptions';
|
||||
|
||||
import { type AwsRegion } from 'src/engine/core-modules/twenty-config/interfaces/aws-region.interface';
|
||||
import { NodeEnvironment } from 'src/engine/core-modules/twenty-config/interfaces/node-environment.interface';
|
||||
@@ -24,6 +25,7 @@ import { LoggerDriverType } from 'src/engine/core-modules/logger/interfaces';
|
||||
import { type MeterDriver } from 'src/engine/core-modules/metrics/types/meter-driver.type';
|
||||
import { ServerlessDriverType } from 'src/engine/core-modules/serverless/serverless.interface';
|
||||
import { CastToLogLevelArray } from 'src/engine/core-modules/twenty-config/decorators/cast-to-log-level-array.decorator';
|
||||
import { CastToTypeORMLogLevelArray } from 'src/engine/core-modules/twenty-config/decorators/cast-to-typeorm-log-level-array.decorator';
|
||||
import { CastToMeterDriverArray } from 'src/engine/core-modules/twenty-config/decorators/cast-to-meter-driver.decorator';
|
||||
import { CastToPositiveNumber } from 'src/engine/core-modules/twenty-config/decorators/cast-to-positive-number.decorator';
|
||||
import { CastToUpperSnakeCase } from 'src/engine/core-modules/twenty-config/decorators/cast-to-upper-snake-case.decorator';
|
||||
@@ -589,6 +591,17 @@ export class ConfigVariables {
|
||||
@IsOptional()
|
||||
TELEMETRY_ENABLED = true;
|
||||
|
||||
@ConfigVariablesMetadata({
|
||||
group: ConfigVariablesGroup.LOGGING,
|
||||
description:
|
||||
'TypeORM logging options for development mode. Accepts comma-separated values: query, schema, error, warn, info, log, migration',
|
||||
type: ConfigVariableType.ARRAY,
|
||||
options: ['query', 'schema', 'error', 'warn', 'info', 'log', 'migration'],
|
||||
})
|
||||
@CastToTypeORMLogLevelArray()
|
||||
@IsOptional()
|
||||
TYPEORM_LOGGING: LoggerOptions = ['error'];
|
||||
|
||||
@ConfigVariablesMetadata({
|
||||
group: ConfigVariablesGroup.BILLING_CONFIG,
|
||||
description: 'Enable or disable billing features',
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
export const CastToTypeORMLogLevelArray = () =>
|
||||
Transform(({ value }: { value: string }) => toTypeORMLogLevelArray(value));
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const toTypeORMLogLevelArray = (value: any) => {
|
||||
if (isNonEmptyString(value)) {
|
||||
const rawLogLevels = value.split(',').map((level) => level.trim());
|
||||
const validLevels = [
|
||||
'query',
|
||||
'schema',
|
||||
'error',
|
||||
'warn',
|
||||
'info',
|
||||
'log',
|
||||
'migration',
|
||||
];
|
||||
const isInvalid = rawLogLevels.some(
|
||||
(level) => !validLevels.includes(level),
|
||||
);
|
||||
|
||||
if (!isInvalid) {
|
||||
return rawLogLevels;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
+1
-10
@@ -3,8 +3,6 @@ import { Injectable, Logger, Optional } from '@nestjs/common';
|
||||
import { isString } from 'class-validator';
|
||||
import { type LoggerOptions } from 'typeorm/logger/LoggerOptions';
|
||||
|
||||
import { NodeEnvironment } from 'src/engine/core-modules/twenty-config/interfaces/node-environment.interface';
|
||||
|
||||
import { ConfigVariables } from 'src/engine/core-modules/twenty-config/config-variables';
|
||||
import { CONFIG_VARIABLES_MASKING_CONFIG } from 'src/engine/core-modules/twenty-config/constants/config-variables-masking-config';
|
||||
import { type ConfigVariablesMetadataOptions } from 'src/engine/core-modules/twenty-config/decorators/config-variables-metadata.decorator';
|
||||
@@ -200,14 +198,7 @@ export class TwentyConfigService {
|
||||
}
|
||||
|
||||
getLoggingConfig(): LoggerOptions {
|
||||
switch (this.get('NODE_ENV')) {
|
||||
case NodeEnvironment.DEVELOPMENT:
|
||||
return ['query', 'error'];
|
||||
case NodeEnvironment.TEST:
|
||||
return [];
|
||||
default:
|
||||
return ['error'];
|
||||
}
|
||||
return this.get('TYPEORM_LOGGING');
|
||||
}
|
||||
|
||||
private validateNotEnvOnly<T extends keyof ConfigVariables>(
|
||||
|
||||
Reference in New Issue
Block a user