Skip to content

Commit

Permalink
chore: add comment on LOGGER_IMPL
Browse files Browse the repository at this point in the history
- update getLoggerImpl logic by adding switch cases
  • Loading branch information
Sai Sankeerth committed Jun 14, 2024
1 parent fd36803 commit a8b0c83
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/logger.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
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';

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) => {
Expand Down

0 comments on commit a8b0c83

Please sign in to comment.