Skip to content

Commit ab1e532

Browse files
committed
Refactor logger configuration and simplify log rotation settings
1 parent 93e5839 commit ab1e532

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

backend/src/services/logger.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import bunyan from 'bunyan';
22
import { existsSync, mkdirSync, readFileSync } from 'fs';
33
import { Request, Response, NextFunction } from 'express';
44
import path, { dirname } from 'path';
5-
import process from 'node:process';
65
import { fileURLToPath } from 'url';
76

87
const __filename = fileURLToPath(import.meta.url);
@@ -18,7 +17,7 @@ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
1817
export const appName = packageJson.name || 'GitHub Value';
1918

2019
const period = process.env.LOG_ROTATION_PERIOD || '1d';
21-
const count = parseInt(process.env.LOG_ROTATION_COUNT ?? '14');
20+
const count = process.env.LOG_ROTATION_COUNT ? parseInt(process.env.LOG_ROTATION_COUNT) : 14;
2221

2322
const logger = bunyan.createLogger({
2423
name: appName,
@@ -47,15 +46,15 @@ const logger = bunyan.createLogger({
4746
{
4847
path: `${logsDir}/error.json`,
4948
type: 'rotating-file',
50-
period: period,
51-
count: count,
49+
period,
50+
count,
5251
level: 'error'
5352
},
5453
{
5554
path: `${logsDir}/debug.json`,
5655
type: 'rotating-file',
57-
period: period,
58-
count: count,
56+
period,
57+
count,
5958
level: 'debug'
6059
}
6160
]

compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ services:
1010
NODE_ENV: production
1111
NODE_OPTIONS: --enable-source-maps
1212
MONGODB_URI: mongodb://root:octocat@mongo:27017
13-
env_file:
14-
- backend/.env
1513
depends_on:
1614
mongo:
1715
condition: service_healthy

0 commit comments

Comments
 (0)