Skip to content

Commit

Permalink
PharmaLedger-IMI/epi-workspace#1077 when OPENDSU_ENABLE_DEBUG is fals…
Browse files Browse the repository at this point in the history
…e then TRACE, DEBUG entries will not be generated
  • Loading branch information
skutner committed Dec 6, 2022
1 parent eb946be commit 7c5ea9b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Logger.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
const envTypes = require("./moduleConstants");
const originalConsole = Object.assign({}, console);
const DEBUG_LOG_ENABLED = process.env.OPENDSU_ENABLE_DEBUG === "true";

if ($$.environmentType === envTypes.NODEJS_ENVIRONMENT_TYPE) {
const logger = new Logger("Logger", "overwrite-require");
logger.log = logger.trace;
if (DEBUG_LOG_ENABLED) {
logger.log = logger.debug;
} else {
logger.log = () => {}
}
Object.assign(console, logger);
}

Expand Down Expand Up @@ -101,7 +107,7 @@ function Logger(className, moduleName, logFile) {
functionName = functions.ERROR;
}

if (functionName === functions.TRACE || functionName === functions.AUDIT) {
if (functionName === functions.AUDIT) {
functionName = functions.LOG;
}

Expand Down Expand Up @@ -153,6 +159,10 @@ function Logger(className, moduleName, logFile) {
printToConsoleAndFile(functions[fnName], ...args);
}
}

if (!DEBUG_LOG_ENABLED) {
this[functions.TRACE] = this[functions.DEBUG] = () => {};
}
}

const getLogger = (className, moduleName, criticalLogFile) => {
Expand Down

0 comments on commit 7c5ea9b

Please # to comment.