From 5e845b8aa6c682e0d47e390f52f15a4b7fad9ab0 Mon Sep 17 00:00:00 2001 From: Adrian Winterstein Date: Sat, 28 Sep 2024 16:23:14 +0200 Subject: [PATCH] Fixed issue that logging was not actually disabled, when no transport were configured in the production environment --- website/server/libs/logger.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/website/server/libs/logger.js b/website/server/libs/logger.js index 1bdf68555d..75152c4adf 100644 --- a/website/server/libs/logger.js +++ b/website/server/libs/logger.js @@ -19,13 +19,14 @@ const logger = winston.createLogger(); const _config = { logger, - loggingEnabled: true, // false if no transport has been configured + loggingEnabled: false, // is set to true, if a transport gets configured }; export { _config as _loggerConfig }; // exported for use during tests if (IS_PROD) { if (ENABLE_CONSOLE_LOGS_IN_PROD) { + _config.loggingEnabled = true; logger .add(new winston.transports.Console({ // text part format: winston.format.combine( @@ -44,6 +45,7 @@ if (IS_PROD) { } if (LOGGLY_TOKEN && LOGGLY_SUBDOMAIN) { + _config.loggingEnabled = true; logger.add(new Loggly({ inputToken: LOGGLY_TOKEN, subdomain: LOGGLY_SUBDOMAIN, @@ -51,8 +53,9 @@ if (IS_PROD) { json: true, })); } -// Do not log anything when testing unless specified + // Do not log anything when testing unless specified } else if (!IS_TEST || (IS_TEST && ENABLE_LOGS_IN_TEST)) { + _config.loggingEnabled = true; logger .add(new winston.transports.Console({ level: 'warn', // warn and errors (text part) @@ -116,8 +119,6 @@ if (IS_PROD) { }), ), })); -} else { - _config.loggingEnabled = false; } // exports a public interface insteaf of accessing directly the logger module