Skip to content

Commit 004bb02

Browse files
authored
Merge pull request #39 from krystxf/feat/be-optional-logs
feat(be): optional logging
2 parents 4317a9d + f8dfa26 commit 004bb02

File tree

4 files changed

+5
-0
lines changed

4 files changed

+5
-0
lines changed

.env.docker.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ REDIS_PORT=6379
2626

2727
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOST}:${DB_PORT}/${POSTGRES_DB}?schema=${DB_SCHEMA}"
2828

29+
LOGS=true

apps/backend/.env.local.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOST}:${DB
2424
# redis
2525
REDIS_HOST=localhost
2626
REDIS_PORT=6379
27+
28+
LOGS=true

apps/backend/src/modules/logger/logger.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class LoggerService extends ConsoleLogger {
4848
| Prisma.InputJsonValue = Prisma.JsonNull,
4949
) {
5050
if (process.env.NODE_ENV === Environment.TEST) return;
51+
if (process.env.LOGS !== "true") return;
5152

5253
await this.prisma.log
5354
.create({

apps/backend/src/schema/env.schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const envSchema = z.object({
1111
REDIS_PORT: z.coerce.number().int().positive().optional(),
1212
REDIS_HOST: z.string().optional(),
1313
PORT: z.coerce.number().int().positive().optional(),
14+
LOGS: z.string().optional(),
1415
});
1516

1617
export type EnvSchema = z.infer<typeof envSchema>;

0 commit comments

Comments
 (0)