Skip to content

Commit

Permalink
chore: added setLoggerLevel method
Browse files Browse the repository at this point in the history
  • Loading branch information
abhilash-sivan committed Dec 24, 2024
1 parent c412fb7 commit 3bb0226
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/collector/src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ exports.init = function init(config, isReInit) {
);

if (process.env['INSTANA_DEBUG']) {
parentLogger.level = 'debug';
setLoggerLevel(parentLogger, 'debug');
} else if (config.level) {
parentLogger.level = config.level;
setLoggerLevel(parentLogger, config.level);
} else if (process.env['INSTANA_LOG_LEVEL']) {
parentLogger.level = process.env['INSTANA_LOG_LEVEL'].toLowerCase();
setLoggerLevel(parentLogger, process.env['INSTANA_LOG_LEVEL'].toLowerCase());
}
}

Expand Down Expand Up @@ -130,3 +130,15 @@ function hasLoggingFunctions(_logger) {
typeof _logger.error === 'function'
);
}

/**
* @param {import("@instana/core/src/core").GenericLogger} _logger
* @param {string|number} level
*/
function setLoggerLevel(_logger, level) {
if (typeof _logger.setLevel === 'function') {
_logger.setLevel(level);
} else {
_logger.level = level;
}
}

0 comments on commit 3bb0226

Please sign in to comment.