From ff4c6fa1bbdfe76c8c4ce6c41a9aa9033901cef2 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Thu, 9 Apr 2026 21:33:54 +0200 Subject: [PATCH] chore: add arguments logging to deprecated MacrosParser method warnings (#5429) Extends the #logDeprecated helper to accept and log the arguments passed to deprecated methods, providing better debugging context for migration. Updates all deprecated method calls (get, has, registerMacro, unregisterMacro) to forward their arguments to the deprecation logger. --- public/scripts/macros.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/public/scripts/macros.js b/public/scripts/macros.js index d3d7a57dd..cbe174264 100644 --- a/public/scripts/macros.js +++ b/public/scripts/macros.js @@ -58,10 +58,11 @@ export class MacrosParser { * * @param {string} method * @param {string} replacement + * @param {IArguments} [methodArgs=null] * @returns {void} */ - static #logDeprecated(method, replacement) { - console.warn(`[DEPRECATED] MacrosParser.${method} is deprecated and will be removed in a future version. Use ${replacement} instead.`); + static #logDeprecated(method, replacement, methodArgs = null) { + console.warn(`[DEPRECATED] MacrosParser.${method} is deprecated and will be removed in a future version. Use ${replacement} instead. Arguments:`, (methodArgs ?? 'none')); } /** @@ -155,7 +156,7 @@ export class MacrosParser { * @returns {string|MacroFunction|undefined} The macro value */ static get(key) { - MacrosParser.#logDeprecated('get', 'macros.registry.getMacro (from scripts/macros/macro-system.js)'); + MacrosParser.#logDeprecated('get', 'macros.registry.getMacro (from scripts/macros/macro-system.js)', arguments); return MacrosParser.#macros.get(key); } @@ -165,7 +166,7 @@ export class MacrosParser { * @returns {boolean} True if the macro is registered, false otherwise */ static has(key) { - MacrosParser.#logDeprecated('has', 'macros.registry.hasMacro (from scripts/macros/macro-system.js)'); + MacrosParser.#logDeprecated('has', 'macros.registry.hasMacro (from scripts/macros/macro-system.js)', arguments); if (power_user.experimental_macro_engine) { return macroSystem.registry.hasMacro(key); } @@ -180,7 +181,7 @@ export class MacrosParser { * @param {string} [description] Optional description of the macro */ static registerMacro(key, value, description = '') { - MacrosParser.#logDeprecated('registerMacro', 'macros.registry.registerMacro (from scripts/macros/macro-system.js) or substituteParams({ dynamicMacros })'); + MacrosParser.#logDeprecated('registerMacro', 'macros.registry.registerMacro (from scripts/macros/macro-system.js) or substituteParams({ dynamicMacros })', arguments); if (typeof key !== 'string') { throw new Error('Macro key must be a string'); } @@ -223,7 +224,7 @@ export class MacrosParser { * @param {string} key Macro name (key) */ static unregisterMacro(key) { - MacrosParser.#logDeprecated('unregisterMacro', 'macros.registry.unregisterMacro (from scripts/macros/macro-system.js)'); + MacrosParser.#logDeprecated('unregisterMacro', 'macros.registry.unregisterMacro (from scripts/macros/macro-system.js)', arguments); if (typeof key !== 'string') { throw new Error('Macro key must be a string'); }