From: Chocobozzz Date: Thu, 12 Dec 2019 16:15:38 +0000 (+0100) Subject: Add max file size, max files and ip anonymize log options X-Git-Tag: v2.1.0-rc.1~217 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2f6b5e2d6ebcac88d9005ea2654ffa77907d5db2;p=oweals%2Fpeertube.git Add max file size, max files and ip anonymize log options --- diff --git a/config/default.yaml b/config/default.yaml index 7c718e174..7fe817aa0 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -86,6 +86,9 @@ log: level: 'info' # debug/info/warning/error rotation: enabled : true + maxFileSize: 12MB + maxFiles: 20 + anonymizeIP: false search: # Add ability to fetch remote videos/actors by their URI, that may not be federated with your instance diff --git a/config/production.yaml.example b/config/production.yaml.example index 98b1669cd..629d0c4b6 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -87,6 +87,9 @@ log: level: 'info' # debug/info/warning/error rotation: enabled : true # Enabled by default, if disabled make sure that 'storage.logs' is pointing to a folder handled by logrotate + maxFileSize: 12MB + maxFiles: 20 + anonymizeIP: false search: # Add ability to fetch remote videos/actors by their URI, that may not be federated with your instance diff --git a/server.ts b/server.ts index b2541eed6..8df3add2c 100644 --- a/server.ts +++ b/server.ts @@ -142,7 +142,7 @@ if (isTestInstance()) { // For the logger morgan.token('remote-addr', req => { - if (req.get('DNT') === '1') { + if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') { return anonymize(req.ip, 16, 16) } diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts index c2ff2bae6..395417612 100644 --- a/server/helpers/logger.ts +++ b/server/helpers/logger.ts @@ -67,9 +67,9 @@ const fileLoggerOptions: FileTransportOptions = { ) } -if (CONFIG.LOG.ROTATION) { - fileLoggerOptions.maxsize = 1024 * 1024 * 12 - fileLoggerOptions.maxFiles = 20 +if (CONFIG.LOG.ROTATION.ENABLED) { + fileLoggerOptions.maxsize = CONFIG.LOG.ROTATION.MAX_FILE_SIZE + fileLoggerOptions.maxFiles = CONFIG.LOG.ROTATION.MAX_FILES } const logger = winston.createLogger({ diff --git a/server/initializers/config.ts b/server/initializers/config.ts index c6e478f57..95b069533 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -93,7 +93,12 @@ const CONFIG = { TRUST_PROXY: config.get('trust_proxy'), LOG: { LEVEL: config.get('log.level'), - ROTATION: config.get('log.rotation.enabled') + ROTATION: { + ENABLED: config.get('log.rotation.enabled'), + MAX_FILE_SIZE: bytes.parse(config.get('log.rotation.maxFileSize')), + MAX_FILES: config.get('log.rotation.maxFiles') + }, + ANONYMIZE_IP: config.get('log.anonymizeIP') }, SEARCH: { REMOTE_URI: {