Skip to content

Commit aae3c88

Browse files
committed
Merge branch 'log-rotation'
2 parents e00d604 + ab1e532 commit aae3c88

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

backend/.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ MONGODB_URI=mongodb://localhost:27017/github-value
1919
# Webhook proxy URL (optional)
2020
# This is only needed if you don't want to use smee.io
2121
# WEBHOOK_PROXY_URL=https://5950-2601-589-4885-e850-b1eb-a754-b856-6038.ngrok-free.app
22+
#
23+
24+
# Log rotation settings
25+
# In observing organizations with large amounts of activity, the debug logs can
26+
# grow quite large, so having flexibility about how long to store those helps.
27+
# LOG_ROTATION_PERIOD=1d
28+
# LOG_ROTATION_COUNT=14

backend/src/services/logger.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const packageJsonPath = path.resolve(__dirname, '../../package.json');
1616
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
1717
export const appName = packageJson.name || 'GitHub Value';
1818

19+
const period = process.env.LOG_ROTATION_PERIOD || '1d';
20+
const count = process.env.LOG_ROTATION_COUNT ? parseInt(process.env.LOG_ROTATION_COUNT) : 14;
21+
1922
const logger = bunyan.createLogger({
2023
name: appName,
2124
level: 'debug',
@@ -42,14 +45,16 @@ const logger = bunyan.createLogger({
4245
},
4346
{
4447
path: `${logsDir}/error.json`,
45-
period: '1d',
46-
count: 14,
48+
type: 'rotating-file',
49+
period,
50+
count,
4751
level: 'error'
4852
},
4953
{
5054
path: `${logsDir}/debug.json`,
51-
period: '1d',
52-
count: 14,
55+
type: 'rotating-file',
56+
period,
57+
count,
5358
level: 'debug'
5459
}
5560
]

0 commit comments

Comments
 (0)