From 08df0c89af2b5d130cfec15e7273ef93f28fadc1 Mon Sep 17 00:00:00 2001 From: Peter Snyder Date: Mon, 23 Oct 2017 03:49:22 -0500 Subject: [PATCH] add the name of each standard that contains the blocked feature to the log, issue #4 --- add-on/lib/proxyblock.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/add-on/lib/proxyblock.js b/add-on/lib/proxyblock.js index a4833c2..1bb0173 100644 --- a/add-on/lib/proxyblock.js +++ b/add-on/lib/proxyblock.js @@ -39,6 +39,19 @@ return prev.concat(standardDefinitions[cur].features); }, []); + // A mapping of feature keypaths to the standards that contain them, + // to make the logs more useful (ie so the log can mention the standard + // that contains the blocked feature). + const featureToStandardMapping = Object + .keys(standardDefinitions) + .reduce(function (mapping, standardName) { + const featuresInStandard = standardDefinitions[standardName].features; + featuresInStandard.forEach(function (featureName) { + mapping[featureName] = standardName; + }); + return mapping; + }, {}); + const toPrimitiveFunc = function (hint) { if (hint === "number" || hint === "default") { return 0; @@ -81,7 +94,9 @@ hasBeenLogged === false && shouldLog) { hasBeenLogged = true; - console.log("Blocked '" + keyPath + "' on '" + hostName + "'"); + const standard = featureToStandardMapping[keyPath]; + const message = `Blocked '${keyPath}' from '${standard}' on '${hostName}'`; + console.log(message); } };