robintw
robintw

Reputation: 28521

How to log from Javascript Module in Firefox extension

I'm modifying a Firefox extension that has been written by someone else, and I'm not very experienced with Javascript and Firefox, so my question is probably fairly simple.

I have a lot of code in a Javascript Module (.jsm file), and I want to produce some outputs form this module to help with debugging. I can't seem to use javascript alerts (alert("blah");) or log to the javascript console (console.log("blah");) as both of these give errors saying that console or alert cannot be found.

Is there any way to produce this sort of debugging output from code running in a Javascript Module? All I want is simple text output to help with my development/debugging process.

Upvotes: 2

Views: 249

Answers (1)

Wladimir Palant
Wladimir Palant

Reputation: 57651

There are two common options:

  • Use dump(), the output will be printed to OS console (on Windows you need to run Firefox with -console command line option to see it).
  • Use Component.utils.reportError, the output will be printed to Error Console - use Ctrl-Shift-J to open it.

Upvotes: 2

Related Questions