Skip to content

Commit

Permalink
fix(back): incorrect pino loglevel default value handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tsa96 committed Sep 27, 2024
1 parent 5c9f6d8 commit d2b070f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/backend/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { APP_FILTER, APP_INTERCEPTOR } from '@nestjs/core';
import { LoggerModule } from 'nestjs-pino';
import { LoggerModule, Params as PinoParams } from 'nestjs-pino';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { FastifyMulterModule } from '@nest-lab/fastify-multer';
import { ExceptionHandlerFilter } from './filters/exception-handler.filter';
Expand Down Expand Up @@ -35,7 +35,7 @@ import { setupNestInterceptor } from '../instrumentation';
// all HTTP requests (so no need for a Nest interceptor).
// In dev mode, outputs as more human-readable strings using `pino-pretty`.
LoggerModule.forRootAsync({
useFactory: async (config: ConfigService) => ({
useFactory: async (config: ConfigService): Promise<PinoParams> => ({
pinoHttp: {
customProps: (_req, _res) => ({ context: 'HTTP' }),
level: config.getOrThrow('logLevel'),
Expand Down
5 changes: 2 additions & 3 deletions apps/backend/src/app/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ export const ConfigFactory = (): ConfigInterface => {
maxCreditsExceptTesters: MAX_CREDITS_EXCEPT_TESTERS,
preSignedUrlExpTime: PRE_SIGNED_URL_EXPIRE_TIME
},
logLevel: ((process.env['LOG_LEVEL'] ?? isTest)
? 'warn'
: 'info') as pino.LevelWithSilent
logLevel: (process.env['LOG_LEVEL'] ??
(isTest ? 'warn' : 'info')) as pino.LevelWithSilent
};
};

Expand Down

0 comments on commit d2b070f

Please sign in to comment.