The Mozilla documentation (https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/console.html) says that I should use console.log
to generate messages from an extension. Those messages are said to appear in the Firefox Error Console. But this is not the case for me. I'm using the Addon builder for the first time today, and I'd like to create an extension that switches tabs on certain events. The tabs are indeed switched, and to a tab which I expected, so my code definitely runs. But the console.log output is nowhere to see.
I have set the filter to "All". All I see are CSS warnings from the addon builder itself.
I have also installed Firebug. It doesn't show anything, too. (This works fine when using console.log from the context of a web page though.) The problem with Firebug would be that it's only enabled for one/some tab anyway, so when switching tabs, it's useless. I need a log window that's always there.
So where will the output from console.log end up?
I guess they changed something, now console.log isn't displayed. I use console.error for debugging, it still shows up in ctrl-shift-j.
This page say something about deprecation of Error Console and using Web Console instead. It's probably related. https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIConsoleService
This doesn't require the sdk.
Just for completeness: in a bootstrapped, non-SDK-based addon, I had to add these two lines in bootstrap.js to have a faked console.log():
Might come in handy for somebody else, I guess..
Instead of doing
var aConsoleService = Cc...
just stick in the following and you can use everything:can now do whatever,
console.log('blah')
,console.time('rawr')
,console.endTime('rawr')
, etc etc etcGo ahead and put a test
console.log("something")
in your addonmain()
;If nothing shows up in the Error Console ('Messages' tab), then maybe Firefox isn't configured to show
console.log
(happened recently with jetpack sdk 1.14). See: Changes to console.log behaviour in SDK 1.14 for details.Quick and dirty summary: In
about:config
setextensions.sdk.console.logLevel
to"all"
Although from your question:
... it sounded like your were already aware of this. So it's not entirely clear what you meant by that.