File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import bunyan from 'bunyan';
22import { existsSync , mkdirSync , readFileSync } from 'fs' ;
33import { Request , Response , NextFunction } from 'express' ;
44import path , { dirname } from 'path' ;
5+ import process from 'node:process' ;
56import { fileURLToPath } from 'url' ;
67
78const __filename = fileURLToPath ( import . meta. url ) ;
@@ -16,6 +17,9 @@ const packageJsonPath = path.resolve(__dirname, '../../package.json');
1617const packageJson = JSON . parse ( readFileSync ( packageJsonPath , 'utf8' ) ) ;
1718export const appName = packageJson . name || 'GitHub Value' ;
1819
20+ const period = process . env . LOG_ROTATION_PERIOD || '1d' ;
21+ const count = parseInt ( process . env . LOG_ROTATION_COUNT ?? '14' ) ;
22+
1923const logger = bunyan . createLogger ( {
2024 name : appName ,
2125 level : 'debug' ,
@@ -42,14 +46,16 @@ const logger = bunyan.createLogger({
4246 } ,
4347 {
4448 path : `${ logsDir } /error.json` ,
45- period : '1d' ,
46- count : 14 ,
49+ type : 'rotating-file' ,
50+ period : period ,
51+ count : count ,
4752 level : 'error'
4853 } ,
4954 {
5055 path : `${ logsDir } /debug.json` ,
51- period : '1d' ,
52- count : 14 ,
56+ type : 'rotating-file' ,
57+ period : period ,
58+ count : count ,
5359 level : 'debug'
5460 }
5561 ]
You can’t perform that action at this time.
0 commit comments