aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohan Fleury <jfleury@arcaik.net>2021-01-07 16:52:37 -0500
committerChocobozzz <chocobozzz@cpy.re>2021-01-13 09:14:43 +0100
commit12c1e38df2fde0efbf948fa80e2afc4e67f0e8c9 (patch)
tree004d31846c078f6e13622fbf2bf0b28bd0db47ea
parentb7085c713220c9c5a96c9bb77330c2ba6ae9274e (diff)
downloadPeerTube-12c1e38df2fde0efbf948fa80e2afc4e67f0e8c9.tar.gz
PeerTube-12c1e38df2fde0efbf948fa80e2afc4e67f0e8c9.tar.zst
PeerTube-12c1e38df2fde0efbf948fa80e2afc4e67f0e8c9.zip
feat: allow administrator to disable logging of ping requests
-rw-r--r--config/default.yaml1
-rw-r--r--config/production.yaml.example1
-rw-r--r--server.ts5
-rw-r--r--server/initializers/config.ts3
-rw-r--r--support/docker/production/config/custom-environment-variables.yaml5
5 files changed, 13 insertions, 2 deletions
diff --git a/config/default.yaml b/config/default.yaml
index d2c713b52..cbe6fa9ea 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -100,6 +100,7 @@ log:
100 maxFileSize: 12MB 100 maxFileSize: 12MB
101 maxFiles: 20 101 maxFiles: 20
102 anonymizeIP: false 102 anonymizeIP: false
103 log_ping_requests: true
103 104
104trending: 105trending:
105 videos: 106 videos:
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 4506ce259..8a3f26a1c 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -100,6 +100,7 @@ log:
100 maxFileSize: 12MB 100 maxFileSize: 12MB
101 maxFiles: 20 101 maxFiles: 20
102 anonymizeIP: false 102 anonymizeIP: false
103 log_ping_requests: true
103 104
104trending: 105trending:
105 videos: 106 videos:
diff --git a/server.ts b/server.ts
index e674a09d4..f844c9564 100644
--- a/server.ts
+++ b/server.ts
@@ -158,7 +158,10 @@ morgan.token('user-agent', (req: express.Request) => {
158 return req.get('user-agent') 158 return req.get('user-agent')
159}) 159})
160app.use(morgan('combined', { 160app.use(morgan('combined', {
161 stream: { write: logger.info.bind(logger) } 161 stream: { write: logger.info.bind(logger) },
162 skip: function (req, res) {
163 return (req.path === '/api/v1/ping' && CONFIG.LOG.LOG_PING_REQUESTS === false)
164 },
162})) 165}))
163 166
164// For body requests 167// For body requests
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 0f58dc1d4..1630f7f0c 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -104,7 +104,8 @@ const CONFIG = {
104 MAX_FILE_SIZE: bytes.parse(config.get<string>('log.rotation.maxFileSize')), 104 MAX_FILE_SIZE: bytes.parse(config.get<string>('log.rotation.maxFileSize')),
105 MAX_FILES: config.get<number>('log.rotation.maxFiles') 105 MAX_FILES: config.get<number>('log.rotation.maxFiles')
106 }, 106 },
107 ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP') 107 ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP'),
108 LOG_PING_REQUESTS: config.get<boolean>('log.log_ping_requests')
108 }, 109 },
109 TRENDING: { 110 TRENDING: {
110 VIDEOS: { 111 VIDEOS: {
diff --git a/support/docker/production/config/custom-environment-variables.yaml b/support/docker/production/config/custom-environment-variables.yaml
index 954c3714b..63459d8a0 100644
--- a/support/docker/production/config/custom-environment-variables.yaml
+++ b/support/docker/production/config/custom-environment-variables.yaml
@@ -42,6 +42,11 @@ smtp:
42 __format: "json" 42 __format: "json"
43 from_address: "PEERTUBE_SMTP_FROM" 43 from_address: "PEERTUBE_SMTP_FROM"
44 44
45log:
46 log_ping_requests:
47 __name: "PEERTUBE_LOG_PING_REQUESTS"
48 __format: "json"
49
45user: 50user:
46 video_quota: 51 video_quota:
47 __name: "PEERTUBE_USER_VIDEO_QUOTA" 52 __name: "PEERTUBE_USER_VIDEO_QUOTA"