4

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?

noname
  • 551
  • 9
  • 29

1 Answers1

4

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!');
Martin Pecka
  • 2,953
  • 1
  • 31
  • 40
speedball2001
  • 947
  • 4
  • 7
  • I didn't know you were using Jetpack. I'm not sure this is being actively developed for Thunderbird. Please test if my modified answer helps. – speedball2001 May 23 '13 at 14:23
  • Yes, I found out I was going the wrong way trying to use Jetpack with Thunderbird. I switched to traditional overlay-based extensions, now it's alright. – noname Jun 21 '13 at 12:40
  • 2
    Is it still relevant in the newer thunderbird versions? like `50.* - 62.*`? – Green Oct 20 '18 at 14:15