From d7d5e04f9276ba3c1cd9ef2c1a09ede1fc9f5ed0 Mon Sep 17 00:00:00 2001 From: Mason Date: Mon, 5 Nov 2018 07:49:03 -0800 Subject: [PATCH] Changed toggle to installation toggle instead of logging toggle --- client/galaxy/scripts/utils/installMonitor.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/client/galaxy/scripts/utils/installMonitor.js b/client/galaxy/scripts/utils/installMonitor.js index ce83ffc19d2..12a9f53a5a0 100644 --- a/client/galaxy/scripts/utils/installMonitor.js +++ b/client/galaxy/scripts/utils/installMonitor.js @@ -6,19 +6,22 @@ * traceroute every time some random script actually accesses window.Bob. */ -import { mock } from "utils/mock"; - -const fakeLogger = mock(console); +// import { mock } from "utils/mock"; +// const fakeLogger = mock(console); // stores values that are returned when somebody asks for window.Something window._monitorStorage = window._monitorStorage || {}; export function installMonitor(globalProp, fallbackValue = null) { - let label = `window.${globalProp}`; let debug = getMonitorToggle(globalProp); - let logger = debug ? console : fakeLogger; - + if (!debug) { + return; + } + + let label = `window.${globalProp}`; + let logger = console; + // initialize storage with existing value let existingValue = window[globalProp] || fallbackValue; window._monitorStorage[globalProp] = existingValue; @@ -38,7 +41,7 @@ export function installMonitor(globalProp, fallbackValue = null) { logger.trace(); logger.groupEnd(); return val; - } catch(err) { + } catch (err) { logger.warn("Unable to retrieve", globalProp, err); } return null; @@ -56,7 +59,7 @@ export function installMonitor(globalProp, fallbackValue = null) { // Proxies the above object definition so we can watch changes to // that object's properties (i.e. window.Thing.prop = "abc") - + return new Proxy({}, { get(o, prop) { logger.groupCollapsed(`${label}.${prop} read`);