From 9a45fa94bd2863a54f1da37c928736da2731db15 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 8 Jun 2015 03:59:16 -0400 Subject: [PATCH] Move transaction wait debug output to level 6, and strip Bluebird lines This output is basically only useful when something hangs, so it can stay off all other times. For now, 6 can be the new only-use-when-something-is-actively-broken level. At some point we may want to move DB activity to 4 and make this sort of thing 5, because we don't have much that's 4 right now. --- chrome/content/zotero/xpcom/db.js | 6 ++++-- chrome/content/zotero/xpcom/debug.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/db.js b/chrome/content/zotero/xpcom/db.js index fa5cd48359..6221b23a6c 100644 --- a/chrome/content/zotero/xpcom/db.js +++ b/chrome/content/zotero/xpcom/db.js @@ -584,8 +584,10 @@ Zotero.DBConnection.prototype.waitForTransaction = function () { if (!this._inTransaction) { return Zotero.Promise.resolve().cancellable(); } - Zotero.debug("Waiting for transaction to finish"); - Zotero.debug((new Error).stack); + if (Zotero.Debug.enabled) { + Zotero.debug("Waiting for transaction to finish", 5); + Zotero.debug(Zotero.Debug.filterStack((new Error).stack), 6); + } return this._transactionPromise; }; diff --git a/chrome/content/zotero/xpcom/debug.js b/chrome/content/zotero/xpcom/debug.js index a2542c1ad5..7db8a74e89 100644 --- a/chrome/content/zotero/xpcom/debug.js +++ b/chrome/content/zotero/xpcom/debug.js @@ -204,4 +204,14 @@ Zotero.Debug = new function () { } return str.substr(1); }; + + + /** + * Strip Bluebird lines from a stack trace + * + * @param {String} stack + */ + this.filterStack = function (stack) { + return stack.split(/\n/).filter(line => line.indexOf('zotero/bluebird') == -1).join('\n'); + } }