]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
feat: allow administrator to disable logging of ping requests
authorJohan Fleury <jfleury@arcaik.net>
Thu, 7 Jan 2021 21:52:37 +0000 (16:52 -0500)
committerChocobozzz <chocobozzz@cpy.re>
Wed, 13 Jan 2021 08:14:43 +0000 (09:14 +0100)
config/default.yaml
config/production.yaml.example
server.ts
server/initializers/config.ts
support/docker/production/config/custom-environment-variables.yaml

index d2c713b526518a547a5d43d971b99f40e9a3efee..cbe6fa9ead8e40f659dda5e9fea84d97ce267073 100644 (file)
@@ -100,6 +100,7 @@ log:
     maxFileSize: 12MB
     maxFiles: 20
   anonymizeIP: false
+  log_ping_requests: true
 
 trending:
   videos:
index 4506ce2596bb3a5ef447d9ef93824c2bf3f47f04..8a3f26a1cff48f599c0cf0b41e61f88b4fc701d5 100644 (file)
@@ -100,6 +100,7 @@ log:
     maxFileSize: 12MB
     maxFiles: 20
   anonymizeIP: false
+  log_ping_requests: true
 
 trending:
   videos:
index e674a09d4a1c7ebfc02863c2116d9d6b48e4aef5..f844c9564b5dacc37ac58cbb8f7d323816650891 100644 (file)
--- 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
index 0f58dc1d4c11ced86be9159545ce221872ade0f7..1630f7f0c8a909c8a38c4985d5a8853dc3f5c71e 100644 (file)
@@ -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: {
index 954c3714b6dc9dd0e2be15d406e9a4d90d990b76..63459d8a044150e01c0afd3f2dab0e19a74bea52 100644 (file)
@@ -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"