diff --git a/packages/api-v2/ormconfig.ts b/packages/api-v2/ormconfig.ts index bfe899ba8..ef71ed03f 100644 --- a/packages/api-v2/ormconfig.ts +++ b/packages/api-v2/ormconfig.ts @@ -3,7 +3,9 @@ import { config } from "dotenv"; import { Plan } from "./src/plan/entities/plan.entity"; import { Student } from "./src/student/entities/student.entity"; -config({ path: `.env.${process.env.NODE_ENV}.local` }); + +// TODO: Probably remove the override. +config({ path: `.env.${process.env.NODE_ENV}.local`, override: true}); const ormconfig: TypeOrmModuleOptions = { type: "postgres", diff --git a/packages/api-v2/src/main.ts b/packages/api-v2/src/main.ts index 2b3cfb3c1..588749fcb 100644 --- a/packages/api-v2/src/main.ts +++ b/packages/api-v2/src/main.ts @@ -1,5 +1,6 @@ import { ClassSerializerInterceptor, + LogLevel, LoggerService, ValidationPipe, } from "@nestjs/common"; @@ -12,8 +13,8 @@ import * as cookieParser from "cookie-parser"; async function bootstrap() { // configure custom logger - const graduateLogger: LoggerService = new GraduateLogger(); - graduateLogger.setLogLevels(["log", "error", "warn", "debug"]); + // TODO: Update context (first param to logger). + const graduateLogger: LoggerService = new GraduateLogger("graduatenu", {logLevels: logLevels(process.env.NODE_ENV)}); const app = await NestFactory.create(AppModule, { logger: graduateLogger, @@ -51,4 +52,12 @@ async function bootstrap() { await app.listen(configService.get("PORT")); } +function logLevels(env: string): LogLevel[] { + // TODO: Is there a constant declared somewhere for this? + if (env === "production") { + return ["error", "warn"]; + } + return ["log", "error", "warn", "debug"]; +} + bootstrap();