ActivityPub-federated video streaming platform using P2P directly in your web browser
Add setting to enable tagging requests
Chocobozzzb332c473c3be
diff --git a/config/config-schema.json b/config/config-schema.jsonindex 08052e404e..7dce7659e3 100644--- a/config/config-schema.json+++ b/config/config-schema.json@@ -932,6 +932,11 @@"type": "boolean","default": false},+ "tag_requests": {+ "description": "Tag every log line produced while handling a request with a request id, and with the authenticated user's username Enable this if you want these values to appear in your logs",+ "type": "boolean",+ "default": false+ },"log_ping_requests": {"type": "boolean","default": truediff --git a/config/default.yaml b/config/default.yamlindex 95c19b5ed5..1cd38e70bc 100644--- a/config/default.yaml+++ b/config/default.yaml@@ -284,6 +284,10 @@ log:anonymize_ip: false+ # Tag every log line produced while handling a request with a request id, and with the authenticated user's username+ # Enable this if you want these values to appear in your logs+ tag_requests: false+log_ping_requests: truelog_tracker_unknown_infohash: truediff --git a/config/production.yaml.example b/config/production.yaml.exampleindex 102c7c1bbe..1bb389a8d9 100644--- a/config/production.yaml.example+++ b/config/production.yaml.example@@ -282,6 +282,10 @@ log:anonymize_ip: false+ # Tag every log line produced while handling a request with a request id, and with the authenticated user's username+ # Enable this if you want these values to appear in your logs+ tag_requests: false+log_ping_requests: truelog_tracker_unknown_infohash: truediff --git a/server/core/initializers/checker-before-init.ts b/server/core/initializers/checker-before-init.tsindex 8cc5dd59fe..4b904c8894 100644--- a/server/core/initializers/checker-before-init.ts+++ b/server/core/initializers/checker-before-init.ts@@ -57,6 +57,7 @@ export function checkMissedConfig () {'log.rotation.max_file_size','log.rotation.max_files','log.anonymize_ip',+ 'log.tag_requests','log.log_ping_requests','log.log_tracker_unknown_infohash','log.prettify_sql',diff --git a/server/core/initializers/config.ts b/server/core/initializers/config.tsindex a06fca0938..8498b25772 100644--- a/server/core/initializers/config.ts+++ b/server/core/initializers/config.ts@@ -519,6 +519,7 @@ const CONFIG = {MAX_FILES: config.get<number>('log.rotation.max_files')},ANONYMIZE_IP: config.get<boolean>('log.anonymize_ip'),+ TAG_REQUESTS: config.get<boolean>('log.tag_requests'),LOG_PING_REQUESTS: config.get<boolean>('log.log_ping_requests'),LOG_TRACKER_UNKNOWN_INFOHASH: config.get<boolean>('log.log_tracker_unknown_infohash'),LOG_HTTP_REQUESTS: config.get<boolean>('log.log_http_requests'),diff --git a/server/core/middlewares/auth.ts b/server/core/middlewares/auth.tsindex bc9c9e6099..522811870c 100644--- a/server/core/middlewares/auth.ts+++ b/server/core/middlewares/auth.ts@@ -5,6 +5,7 @@ import { RunnerModel } from '@server/models/runner/runner.js'import express from 'express'import { Socket } from 'socket.io'import { addLoggerContextTags, createLogger } from '../helpers/logger.js'+import { CONFIG } from '../initializers/config.js'import { handleOAuthAuthenticate } from '../lib/auth/oauth-handlers.js'const logger = createLogger()@@ -22,7 +23,7 @@ export function authenticate (req: express.Request, res: express.Response, next:})// A global middleware create the context- addLoggerContextTags(token.User.username)+ if (CONFIG.LOG.TAG_REQUESTS) addLoggerContextTags(token.User.username)return next()})diff --git a/server/core/middlewares/logger-context.ts b/server/core/middlewares/logger-context.tsindex 8691df78c1..245538f367 100644--- a/server/core/middlewares/logger-context.ts+++ b/server/core/middlewares/logger-context.ts@@ -1,5 +1,6 @@import { buildSUUID } from '@peertube/peertube-node-utils'import express from 'express'+import { CONFIG } from '../initializers/config.js'import { inLoggerContext } from '../helpers/logger.js'// Tag every logger call happening while handling this request (including in async code) with a request id,@@ -9,5 +10,7 @@ export function requestLoggerContext (_req: express.Request, res: express.Responres.setHeader('X-Request-Id', requestId)+ if (!CONFIG.LOG.TAG_REQUESTS) return next()+inLoggerContext([ 'req', requestId ], () => next())}diff --git a/support/docker/production/config/custom-environment-variables.yaml b/support/docker/production/config/custom-environment-variables.yamlindex 2b659cc848..ede4b54708 100644--- a/support/docker/production/config/custom-environment-variables.yaml+++ b/support/docker/production/config/custom-environment-variables.yaml@@ -290,6 +290,9 @@ log:anonymize_ip:__name: PEERTUBE_LOG_ANONYMIZE_IP__format: json+ tag_requests:+ __name: PEERTUBE_LOG_TAG_REQUESTS+ __format: jsonlog_tracker_unknown_infohash:__name: PEERTUBE_LOG_LOG_TRACKER_UNKNOWN_INFOHASH__format: json