Question

I have the following code in my bootstrapped Thunderbird add-on main.js file:

exports.main = function() {
    console.log("abc");
};

When I run this code in FireFox in Add-on Builder, I get this message displayed in FireFox Error Console:

info: vladp: abc

However, when I run my extension in Thunderbird nothing is displayed. I have set up the development enviroment as described here: https://developer.mozilla.org/en-US/docs/Setting_up_extension_development_environment

How do I make it work in Thunderbird Error Console? Or is there any other way to log some debug information, apart from "dump()"?

UPDATE 1

As suggested by speedball2001, I've changed my code to:

exports.main = function() { 
    var Application = Components.classes["@mozilla.org/steel/application;1"].getService(Components.interfaces.steelIApplication);
    Application.console.log('Bam!');
};

However, when I run Thunderbird, I get the following error in error console:

Timestamp: 2013.05.22. 16:39:07
Error: myfirstext: An exception occurred.
ReferenceError: Components is not defined
resource://jid0-7yp22cmsooypei7nicamg3n0ha0-at-jetpack/myfirstext/lib/main.js 57

How do I fix it?

Was it helpful?

Solution

Thunderbird provides an Application interface that, among other things, helps with logging:

var {Cc, Ci} = require("chrome");
var Application = Cc["@mozilla.org/steel/application;1"]
                    .getService(Ci.steelIApplication);

Application.console.log('Bam!');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top