@opuscapita/logger
Advanced tools
Comparing version 1.5.0 to 1.6.0
32
index.js
@@ -12,3 +12,7 @@ 'use strict' | ||
let debugMode = false; | ||
const loggerConfigFilename = 'logger.json'; | ||
const loggerConfigFilenames = [ | ||
process.env.LOGGER_CONFIG_FILE, | ||
'etc/logger.json', | ||
'logger.json' | ||
]; | ||
const _defaultFormatOptions = { | ||
@@ -402,3 +406,2 @@ // See https://nodejs.org/api/util.html#utilinspectobject-options | ||
try { | ||
_info.write('Loading logger config file...\n'); | ||
const data = fs.readFileSync(filename, 'utf8', 'r'); | ||
@@ -473,15 +476,24 @@ const cfgFile = JSON.parse(data); | ||
catch (e) { | ||
_error.write(`Cannot parse logger config file: ${e.message}\n`); | ||
return false; | ||
switch (e.code) { | ||
case 'ENOENT': | ||
break; | ||
default: | ||
_error.write(`Cannot parse logger config file: ${e.message}\n`); | ||
} | ||
return false; | ||
} | ||
}; | ||
if (loadConfigFile(loggerConfigFilename)) { | ||
for (const idx in loggerConfigFilenames) { | ||
const loggerConfigFilename = loggerConfigFilenames[idx]; | ||
if (loggerConfigFilename && loadConfigFile(loggerConfigFilename)) { | ||
_info.write(`Logger config file loaded (${loggerConfigFilename}), monitoring for changes\n`); | ||
fs.watch( | ||
loggerConfigFilename, | ||
{persistent: false, recursive: false, encoding: 'utf8'/*, signal: abortController*/}, | ||
(event, filename) => { | ||
_info.write(`Logger config change detected ${event}\n`); | ||
loadConfigFile(filename); | ||
loggerConfigFilename, | ||
{persistent: false, recursive: false, encoding: 'utf8'/*, signal: abortController*/}, | ||
(event, filename) => { | ||
_info.write(`Logger config change detected ${event}\n`); | ||
loadConfigFile(filename); | ||
}); | ||
}; | ||
}; |
{ | ||
"name": "@opuscapita/logger", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Unified logging component for OpusCapita Andariel platform.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22643
454
2