Use firebug console logging in your extensions

3 views
Skip to first unread message

stechz

unread,
May 3, 2009, 9:28:28 PM5/3/09
to Portland Firefox Development
So I doubt this is the best way to use Firebug logging in an
extension, but it works. The log appears in the Firebug context for
the currently focused window. In the case that Firebug is disabled or
you need logging for browser startup, it also logs to the Firefox
console.

function debug(aMessage) {
try {
var objects = [];
objects.push.apply(objects, arguments);
Firebug.Console.logFormatted(objects,
TabWatcher.getContextByWindow
(content.document.defaultView.wrappedJSObject));
}
catch (e) {
}

var consoleService = Components.classes["@mozilla.org/
consoleservice;1"].getService
(Components.interfaces.nsIConsoleService);
if (aMessage === "") consoleService.logStringMessage
("(empty string)");
else if (aMessage != null) consoleService.logStringMessage
(aMessage.toString());
else consoleService.logStringMessage("null");
}
Reply all
Reply to author
Forward
0 new messages