From 912136b163790f70f2d82600f6782ed93bc2ba9a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 26 Aug 2021 18:46:26 +0200 Subject: [PATCH] Add support for deprecated configuration key in a section MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils/Configuration.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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}`); } } -- 2.34.1