feat: allow administrator to disable logging of ping requests

pull/3592/head
Johan Fleury 2021-01-07 16:52:37 -05:00 committed by Chocobozzz
parent b7085c7132
commit 12c1e38df2
5 changed files with 13 additions and 2 deletions

View File

@ -100,6 +100,7 @@ log:
maxFileSize: 12MB maxFileSize: 12MB
maxFiles: 20 maxFiles: 20
anonymizeIP: false anonymizeIP: false
log_ping_requests: true
trending: trending:
videos: videos:

View File

@ -100,6 +100,7 @@ log:
maxFileSize: 12MB maxFileSize: 12MB
maxFiles: 20 maxFiles: 20
anonymizeIP: false anonymizeIP: false
log_ping_requests: true
trending: trending:
videos: videos:

View File

@ -158,7 +158,10 @@ morgan.token('user-agent', (req: express.Request) => {
return req.get('user-agent') return req.get('user-agent')
}) })
app.use(morgan('combined', { 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 // For body requests

View File

@ -104,7 +104,8 @@ const CONFIG = {
MAX_FILE_SIZE: bytes.parse(config.get<string>('log.rotation.maxFileSize')), MAX_FILE_SIZE: bytes.parse(config.get<string>('log.rotation.maxFileSize')),
MAX_FILES: config.get<number>('log.rotation.maxFiles') 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: { TRENDING: {
VIDEOS: { VIDEOS: {

View File

@ -42,6 +42,11 @@ smtp:
__format: "json" __format: "json"
from_address: "PEERTUBE_SMTP_FROM" from_address: "PEERTUBE_SMTP_FROM"
log:
log_ping_requests:
__name: "PEERTUBE_LOG_PING_REQUESTS"
__format: "json"
user: user:
video_quota: video_quota:
__name: "PEERTUBE_USER_VIDEO_QUOTA" __name: "PEERTUBE_USER_VIDEO_QUOTA"