From a8b0c8380831a5d9072b176d1ad5ecd64b54583c Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Fri, 14 Jun 2024 14:03:52 +0530 Subject: [PATCH] chore: add comment on LOGGER_IMPL - update getLoggerImpl logic by adding switch cases --- src/logger.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/logger.js b/src/logger.js index 85d4a11255..1e51fbdb81 100644 --- a/src/logger.js +++ b/src/logger.js @@ -1,9 +1,7 @@ -const dotenv = require('dotenv'); - /* istanbul ignore file */ const { LOGLEVELS, structuredLogger } = require('@rudderstack/integrations-lib'); -// any value greater than levelError will work as levelNone +// LOGGER_IMPL can be `console` or `winston` const loggerImpl = process.env.LOGGER_IMPL ?? 'winston'; let logLevel = process.env.LOG_LEVEL ?? 'error'; @@ -11,7 +9,12 @@ let logLevel = process.env.LOG_LEVEL ?? 'error'; const logger = structuredLogger({ level: logLevel }); const getLogger = () => { - return loggerImpl === 'winston' ? logger : console; + switch (loggerImpl) { + case 'winston': + return logger; + case 'console': + return console; + } }; const setLogLevel = (level) => {