Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Simplify the environment variable checking
Browse files Browse the repository at this point in the history
The length checks are redundant.
  • Loading branch information
rowanmanning committed Jul 11, 2022
1 parent da56af8 commit 73942f4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ const getLogger = () => {
} else {
// app environment - use Winston

// Determine whether the app is using Heroku log drains
const useHerokuLogDrains = (
process.env.MIGRATE_TO_HEROKU_LOG_DRAINS &&
process.env.MIGRATE_TO_HEROKU_LOG_DRAINS.length > 0
);
// Determine whether the app is using Heroku log drains or Splunk HEC
const useHerokuLogDrains = process.env.MIGRATE_TO_HEROKU_LOG_DRAINS;
const splunkToken = process.env.SPLUNK_HEC_TOKEN;

// Determine the log level
let logLevel = 'silly';
Expand All @@ -33,7 +31,7 @@ const getLogger = () => {

// If we have a Splunk token and we're not using log drains,
// then add a Splunk HEC transport to the logger
if (!useHerokuLogDrains && process.env.SPLUNK_HEC_TOKEN && process.env.SPLUNK_HEC_TOKEN.length > 0) {
if (splunkToken && !useHerokuLogDrains) {
logger.addSplunkHEC(process.env.SPLUNK_LOG_LEVEL || 'warn');
}

Expand Down

0 comments on commit 73942f4

Please sign in to comment.