Closed Bug 791171 Opened 12 years ago Closed 11 years ago

Refactor/reduce logging function boilerplate in Add-ons Manager

Categories

(Toolkit :: Add-ons Manager, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 661982

People

(Reporter: Unfocused, Unassigned)

Details

We use AddonLogger.jsm to handle logging in all the backend Addons Manager code, which currently requires the same boilerplate code every time: ["LOG", "WARN", "ERROR"].forEach(function(aName) { this.__defineGetter__(aName, function logFuncGetter() { Components.utils.import("resource://gre/modules/AddonLogging.jsm"); LogManager.getLogger("addons.xpi", this); return this[aName]; }) }, this); Which is used to make it so the JSM is lazy loaded, and the logging functions are lazily created. However, I don't think we actually benefit from that - we always call LOG() on startup - so AddonLogging.jsm is always loaded on startup anyway. At the very least, that code can be refactored so the lazy logging functions are created by AddonLogger.jsm itself. Something like: Cu.import("resource://gre/modules/AddonLogging.jsm"); LogManager.defineLazyLoggers("addons.xpi", this); For the likes of AddonManager.jsm and XPIProvider.jsm that use logging extensively (including on startup), we should just skip over the lazy step and use LogManager.getLogger() directly.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.