From: Jérôme Benoit Date: Thu, 26 Aug 2021 16:46:26 +0000 (+0200) Subject: Add support for deprecated configuration key in a section X-Git-Tag: v1.0.45~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=912136b163790f70f2d82600f6782ed93bc2ba9a;p=e-mobility-charging-stations-simulator.git Add support for deprecated configuration key in a section Signed-off-by: Jérôme Benoit --- diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 60092940..bad98a98 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -133,8 +133,11 @@ export default class Configuration { return new Date().toLocaleString() + ' Simulator configuration |'; } - private static warnDeprecatedConfigurationKey(key: string, logMsgToAppend = '') { - if (!Configuration.isUndefined(Configuration.getConfig()[key])) { + private static warnDeprecatedConfigurationKey(key: string, sectionName?: string, logMsgToAppend = '') { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + if (sectionName && !Configuration.isUndefined(Configuration.getConfig()[sectionName]) && !Configuration.isUndefined(Configuration.getConfig()[sectionName][key])) { + console.error(`${Configuration.logPrefix()} Deprecated configuration key '${key}' usage in section '${sectionName}'${logMsgToAppend && '. ' + logMsgToAppend}`); + } else if (!Configuration.isUndefined(Configuration.getConfig()[key])) { console.error(`${Configuration.logPrefix()} Deprecated configuration key '${key}' usage${logMsgToAppend && '. ' + logMsgToAppend}`); } }