diff --git a/api/src/common/utils/shared.utils.ts b/api/src/common/utils/shared.utils.ts
index 8f1ed083dd7caeee9ccbe56f82c94dd77d0c10b2..5b41abeae2e430542f9c75440c2633d784698a63 100644
--- a/api/src/common/utils/shared.utils.ts
+++ b/api/src/common/utils/shared.utils.ts
@@ -2,15 +2,28 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
import {
- BadRequestException,
HttpException,
InternalServerErrorException,
+ LogLevel,
NotFoundException,
RequestTimeoutException,
UnauthorizedException,
} from '@nestjs/common';
import axios from 'axios';
+export const LOG_LEVELS = [
+ ['warn', 'error'],
+ ['warn', 'error', 'log'],
+ ['warn', 'error', 'log', 'verbose'],
+ ['warn', 'error', 'log', 'verbose', 'log'],
+];
+
+export const getLogLevels = (level: number): LogLevel[] => {
+ let internLevel = level - 1;
+ if (internLevel > LOG_LEVELS.length || internLevel < 0) internLevel = 0;
+ return LOG_LEVELS[internLevel] as LogLevel[];
+};
+
export const errorAxiosHandler = (e: any) => {
if (!axios.isAxiosError(e)) throw new InternalServerErrorException(e);
diff --git a/api/src/main.ts b/api/src/main.ts
index 6e6fe7b0003a717eba3198989da8e91eaf85afa2..7caa98df79bdb4f135a09809255b6351863cc89a 100644
--- a/api/src/main.ts
+++ b/api/src/main.ts
@@ -1,9 +1,14 @@
import { NestFactory } from '@nestjs/core';
import { NestExpressApplication } from '@nestjs/platform-express';
-import { AppModule } from './main/app.module';
import * as cookieParser from 'cookie-parser';
+import { getLogLevels } from './common/utils/shared.utils';
+import { AppModule } from './main/app.module';
const CORS_URL = process.env.CORS_URL ?? process.env.ENGINE_BASE_URL;
+const DEFAULT_LEVEL = process.env.NODE_ENV === 'production' ? 1 : 4;
+const LOG_LEVEL = process.env.LOG_LEVEL
+ ? parseInt(process.env.LOG_LEVEL)
+ : DEFAULT_LEVEL;
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
@@ -15,6 +20,7 @@ async function bootstrap() {
CORS_URL,
],
},
+ logger: getLogLevels(LOG_LEVEL),
});
app.use(cookieParser());