Skip to content
This repository was archived by the owner on Mar 2, 2025. It is now read-only.

Commit

Permalink
Merge pull request #231 from IKatsuba/logs
Browse files Browse the repository at this point in the history
fix: JSON logs for non local environment
  • Loading branch information
IKatsuba authored Sep 19, 2023
2 parents 933a069 + 6eb34a4 commit 659b7b7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
23 changes: 14 additions & 9 deletions apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ import { PrometheusStatsModule } from '@nx-turbo/api-stats';
envFilePath: '.env',
isGlobal: true,
}),
LoggerModule.forRoot({
pinoHttp: {
level: environment.production ? 'info' : 'debug',
transport: {
target: 'pino-pretty',
options: {
colorize: true,
},
LoggerModule.forRootAsync({
useFactory: (configService: ConfigService<Environment>) => ({
pinoHttp: {
level: configService.get('LOG_LEVEL', 'info'),
transport: environment.production
? undefined
: {
target: 'pino-pretty',
options: {
colorize: true,
},
},
},
},
}),
inject: [ConfigService],
}),
ApiAuthModule,
MikroOrmModule.forRootAsync({
Expand Down
13 changes: 13 additions & 0 deletions libs/api/models/src/lib/environment.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { LevelWithSilent } from 'pino';

export interface Environment {
PORT: string;

// DB starts here
DB_HOST: string;
DB_PORT: string;
DB_NAME: string;
DB_PASSWORD: string;
DB_USER: string;
// DB ends here

JWT_SECRET: string;

// AWS starts here
AWS_S3_ENDPOINT_URL: string;
AWS_REGION: string;
AWS_ACCESS_KEY_ID: string;
Expand All @@ -14,4 +22,9 @@ export interface Environment {

AWS_ROLE_ARN: string;
AWS_WEB_IDENTITY_TOKEN_FILE: string;
// AWS ends here

// LOG starts here
LOG_LEVEL: LevelWithSilent;
// LOG ends here
}

0 comments on commit 659b7b7

Please sign in to comment.