From a04f6980c23a0b1a6ee253963d12c9d10b34a0ff Mon Sep 17 00:00:00 2001 From: Johan Fleury Date: Thu, 7 Jan 2021 16:52:37 -0500 Subject: [PATCH] feat: allow administrator to disable logging of ping requests --- config/default.yaml | 1 + config/production.yaml.example | 1 + server.ts | 5 ++++- server/initializers/config.ts | 3 ++- .../production/config/custom-environment-variables.yaml | 5 +++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/default.yaml b/config/default.yaml index 9d428f764fde..7d068d883f49 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -99,6 +99,7 @@ log: maxFileSize: 12MB maxFiles: 20 anonymizeIP: false + log_ping_requests: true trending: videos: diff --git a/config/production.yaml.example b/config/production.yaml.example index bcf727d82541..4f916842d373 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -100,6 +100,7 @@ log: maxFileSize: 12MB maxFiles: 20 anonymizeIP: false + log_ping_requests: false trending: videos: diff --git a/server.ts b/server.ts index edfbab3d7f34..3e5b8b8433bb 100644 --- a/server.ts +++ b/server.ts @@ -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 diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 705223b0adcf..14edfb72cbe5 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -104,7 +104,8 @@ const CONFIG = { MAX_FILE_SIZE: bytes.parse(config.get('log.rotation.maxFileSize')), MAX_FILES: config.get('log.rotation.maxFiles') }, - ANONYMIZE_IP: config.get('log.anonymizeIP') + ANONYMIZE_IP: config.get('log.anonymizeIP'), + LOG_PING_REQUESTS: config.get('log.log_ping_requests') }, TRENDING: { VIDEOS: { diff --git a/support/docker/production/config/custom-environment-variables.yaml b/support/docker/production/config/custom-environment-variables.yaml index c4c627551713..c87e634d1cd3 100644 --- a/support/docker/production/config/custom-environment-variables.yaml +++ b/support/docker/production/config/custom-environment-variables.yaml @@ -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"