Thunderbird扩展控制台日志记录

时间:2013-05-22 08:23:27

标签: firefox-addon firefox-addon-sdk thunderbird thunderbird-addon error-console

我的自举Thunderbird附加组件main.js文件中有以下代码:

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

当我在Add-on Builder中的FireFox中运行此代码时,我在FireFox错误控制台中显示此消息:

info: vladp: abc

但是,当我在Thunderbird中运行我的扩展程序时,不会显示任何内容。我已按照此处所述设置了开发环境:https://developer.mozilla.org/en-US/docs/Setting_up_extension_development_environment

如何在Thunderbird错误控制台中使其工作?或者除了“dump()”之外还有其他方法来记录一些调试信息吗?

更新1

正如speedball2001所建议的,我已将代码更改为:

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

但是,当我运行Thunderbird时,我在错误控制台中收到以下错误:

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

我该如何解决?

1 个答案:

答案 0 :(得分:3)

Thunderbird提供Application接口,除其他外,还有助于记录:

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

Application.console.log('Bam!');