From 15252623d77c24ac6852dcccc5292ef0d325ae58 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 29 May 2015 03:37:29 -0400 Subject: [PATCH] Log the actual number of Notifier observers for a type --- chrome/content/zotero/xpcom/notifier.js | 32 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/notifier.js b/chrome/content/zotero/xpcom/notifier.js index 784479b935..d5179b53a4 100644 --- a/chrome/content/zotero/xpcom/notifier.js +++ b/chrome/content/zotero/xpcom/notifier.js @@ -119,11 +119,20 @@ Zotero.Notifier = new function(){ var queue = _inTransaction && !force; - Zotero.debug("Notifier.trigger('" + event + "', '" + type + "', " + '[' + ids.join() + '], ' + extraData + ')' - + (queue ? " queued" : " called " + "[observers: " + Object.keys(_observers).length + "]")); - if (extraData) { - Zotero.debug("Extra data:"); - Zotero.debug(extraData); + if (Zotero.Debug.enabled) { + Zotero.debug("Notifier.trigger(" + + "'" + event + "', " + + "'" + type + "', " + + "[" + ids.join() + "]" + + (extraData ? ", " + extraData : "") + + ")" + + (queue + ? " queued" + : " called " + "[observers: " + _countObserversForType(type) + "]") + ); + if (extraData) { + Zotero.debug(extraData); + } } // Merge with existing queue @@ -215,6 +224,19 @@ Zotero.Notifier = new function(){ } + function _countObserversForType(type) { + var num = 0; + for (let i in _observers) { + // Skip observers that don't handle notifications for this type (or all types) + if (_observers[i].types && _observers[i].types.indexOf(type) == -1) { + continue; + } + num++; + } + return num; + } + + this.untrigger = function (event, type, ids) { if (!_inTransaction) { throw ("Zotero.Notifier.untrigger() called with no active event queue")