From a771c43989b04e18f5739a0d28800df139bf0441 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Wed, 25 May 2016 12:35:58 +0200 Subject: [PATCH] feat(test): allow logs to show up when testing --- config.json.example | 1 + website/server/libs/api-v3/logger.js | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config.json.example b/config.json.example index 9d37d70db7..01c549c803 100644 --- a/config.json.example +++ b/config.json.example @@ -9,6 +9,7 @@ "NODE_DB_URI":"mongodb://localhost/habitrpg", "TEST_DB_URI":"mongodb://localhost/habitrpg_test", "NODE_ENV":"development", + "ENABLE_CONSOLE_LOGS_IN_TEST": false, "CRON_SAFE_MODE":"false", "CRON_SEMI_SAFE_MODE":"false", "MAINTENANCE_MODE": "false", diff --git a/website/server/libs/api-v3/logger.js b/website/server/libs/api-v3/logger.js index 9c1c05805c..a5a46fec87 100644 --- a/website/server/libs/api-v3/logger.js +++ b/website/server/libs/api-v3/logger.js @@ -5,20 +5,19 @@ import _ from 'lodash'; const IS_PROD = nconf.get('IS_PROD'); const IS_TEST = nconf.get('IS_TEST'); -const ENABLE_CONSOLE_LOGS_IN_PROD = nconf.get('ENABLE_CONSOLE_LOGS_IN_PROD') === 'true'; +const ENABLE_LOGS_IN_TEST = nconf.get('ENABLE_CONSOLE_LOGS_IN_TEST') === 'true'; +const ENABLE_LOGS_IN_PROD = nconf.get('ENABLE_CONSOLE_LOGS_IN_PROD') === 'true'; const logger = new winston.Logger(); if (IS_PROD) { - if (ENABLE_CONSOLE_LOGS_IN_PROD) { + if (ENABLE_LOGS_IN_PROD) { logger.add(winston.transports.Console, { colorize: false, prettyPrint: false, }); } -} else if (IS_TEST) { - // Do not log anything when testing -} else { +} else if (!IS_TEST || IS_TEST && ENABLE_LOGS_IN_TEST) { // Do not log anything when testing unless specified logger .add(winston.transports.Console, { colorize: true,