Skip to content

Commit

Permalink
feat: allow administrator to disable logging of ping requests
Browse files Browse the repository at this point in the history
  • Loading branch information
johanfleury committed Jan 7, 2021
1 parent 14d3bb9 commit a04f698
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ log:
maxFileSize: 12MB
maxFiles: 20
anonymizeIP: false
log_ping_requests: true

trending:
videos:
Expand Down
1 change: 1 addition & 0 deletions config/production.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ log:
maxFileSize: 12MB
maxFiles: 20
anonymizeIP: false
log_ping_requests: false

trending:
videos:
Expand Down
5 changes: 4 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ morgan.token('user-agent', (req: express.Request) => {
return req.get('user-agent')
})
app.use(morgan('combined', {
stream: { write: logger.info.bind(logger) }
stream: { write: logger.info.bind(logger) },
skip: function (req, res) {
return (req.path === '/api/v1/ping' && CONFIG.LOG.LOG_PING_REQUESTS === false)
},
}))

// For body requests
Expand Down
3 changes: 2 additions & 1 deletion server/initializers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ const CONFIG = {
MAX_FILE_SIZE: bytes.parse(config.get<string>('log.rotation.maxFileSize')),
MAX_FILES: config.get<number>('log.rotation.maxFiles')
},
ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP')
ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP'),
LOG_PING_REQUESTS: config.get<boolean>('log.log_ping_requests')
},
TRENDING: {
VIDEOS: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ smtp:
__format: "json"
from_address: "PEERTUBE_SMTP_FROM"

log:
log_ping_requests:
__name: "PEERTUBE_LOG_PING_REQUESTS"
__format: "json"

user:
video_quota:
__name: "PEERTUBE_USER_VIDEO_QUOTA"
Expand Down

0 comments on commit a04f698

Please sign in to comment.