I'm writing an extension for Firefox, and I need to log some data to Firebug's console. Within the scope of my addon, "console" is undefined, and "window.content.console" is also undefined. So how do I log to the console?
相关问题
- Pass custom debug information to Microsoft bot fra
- I want to trace logs using a Macro multi parameter
- Error message 'No handlers could be found for
- convert logback.xml to log4j.properties
- Django management command doesn't show logging
相关文章
- how do I log requests and responses for debugging
- Firefox remembering radio buttons incorrectly
- How do I get to see DbgPrint output from my kernel
- Android Studio doesn't display logs by package
- Advanced profiling is unavailable for the selected
- Can't Inspect Variables When Debugging .NET As
- What is the difference between glibc's MALLOC_
- CSS Firefox box-shadow and outline
There are contexts in which even the Firebug object is unknown, like if you're trying to call it from a sidebar... in which case you have to go all the way back to the original window to get the firebug object:
You can then from within your sidebar call Firebug like so:
This is documented here: https://developer.mozilla.org/en/Code_snippets/Sidebar
To log to the console from inside a firefox extension’s javascript:
Application.console.log("Hello from my Firefox Extension!");
Since you're not writing Javascript that executes within a window,
console
is not defined.So you need to reference the Firebug extension first:
If in your extension you have access to the content Window object, you can unwrap it, and call the console methods directly:
Firebug console is associated with a particular page, so it wouldn't be very convenient even if you managed to log messages there. Did you try Chromebug? I didn't use it, but I would expect to find a similar console for extensions to use there.
You could also use the regular Error Console, although you won't get all the niceties Firebug's console provides. You could install Console^2 https://addons.mozilla.org/en-US/firefox/addon/1815 to make using the Error Console a little less painful.
As far as I know you can only do that if you are creating a JetPack Add-on. Normal debugging is done with Venkman from Mozilla at http://www.mozilla.org/projects/venkman/