Skip to content

Commit

Permalink
better logs in configService
Browse files Browse the repository at this point in the history
  • Loading branch information
manfredipist committed Feb 28, 2024
1 parent 7fd1f97 commit 7230eb3
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions lib/configService.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,6 @@ function processEnvironmentVariables() {
protectedVariables.forEach((key) => {
iotAgentLib.configModule.getSecretData(key);
});
iotaVariables.forEach((key) => {
let value = process.env[key];
if (value) {
logger.info('Setting IoTAgent Lib environment variable %s to environment value: %s', key, value);
}
});
opcUAVariables.forEach((key) => {
let value = process.env[key];
if (value) {
if (key.endsWith('USERNAME') || key.endsWith('PASSWORD') || key.endsWith('KEY')) {
value = '********';
}
logger.info('Setting opcUA environment variable %s to environment value: %s', key, value);
}
});
mappingToolVariables.forEach((key) => {
let value = process.env[key];
if (value) {
logger.info('Setting mappingTool environment variable %s to environment value: %s', key, value);
}
});

if (process.env.IOTA_CONFIG_RETRIEVAL) {
config.configRetrieval = process.env.IOTA_CONFIG_RETRIEVAL;
Expand All @@ -128,8 +107,16 @@ function processEnvironmentVariables() {
deviceRegistry: {},
mongodb: {}
};
logger.info('Config.iota erased', config.iota);
}

iotaVariables.forEach((key) => {
let value = process.env[key];
if (value) {
logger.info('Setting IoTAgent Lib environment variable %s to environment value: %s', key, value);
}
});

if (process.env.IOTA_LOGLEVEL) {
config.iota.logLevel = process.env.IOTA_LOGLEVEL;
}
Expand Down Expand Up @@ -222,8 +209,19 @@ function processEnvironmentVariables() {
config.opcua = {
subscription: {}
};
logger.info('Config.opcua erased', config.opcua);
}

opcUAVariables.forEach((key) => {
let value = process.env[key];
if (value) {
if (key.endsWith('USERNAME') || key.endsWith('PASSWORD') || key.endsWith('KEY')) {
value = '********';
}
logger.info('Setting opcUA environment variable %s to environment value: %s', key, value);
}
});

if (process.env.IOTA_OPCUA_ENDPOINT) {
config.opcua.endpoint = process.env.IOTA_OPCUA_ENDPOINT;
}
Expand Down Expand Up @@ -274,8 +272,16 @@ function processEnvironmentVariables() {

if (anyIsSet(mappingToolVariables)) {
config.mappingTool = {};
logger.info('Config.mappingTool erased', config.mappingTool);
}

mappingToolVariables.forEach((key) => {
let value = process.env[key];
if (value) {
logger.info('Setting mappingTool environment variable %s to environment value: %s', key, value);
}
});

if (process.env.IOTA_OPCUA_MT_POLLING) {
config.mappingTool.polling = process.env.IOTA_OPCUA_MT_POLLING;
}
Expand Down

0 comments on commit 7230eb3

Please sign in to comment.