How can I dump log messages from Java code in Firefox extension?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I dump log messages from Java code in Firefox extension?

Sachiko Yoshihama
Hi,

I can call a Java code I wrote from a Firefox extension written in
JavaScrpit, using the workaround described at:
https://developer.mozilla.org/en/Java_in_Firefox_Extensions

But when I try to dump some debug messages by using Logger or
System.out, nothing appears in the console of Firefox.
What is a good way of recording log messages in JavaCode that is
called from a Firefox extension?

Just to be clear, what I mean by the console is the command-line
window that shows up when you invoke firefox.exe with the "-console"
option.
I changed the value of "browser.dom.window.dump.enabled"  to true, and
I can successfully log messages by dump() in JavaScript code.

Sachiko
_______________________________________________
dev-tech-java mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-java
Reply | Threaded
Open this post in threaded view
|

Re: How can I dump log messages from Java code in Firefox extension?

brettz9
On 1/9/2010 4:29 PM, Sachiko Yoshihama wrote:

> I can call a Java code I wrote from a Firefox extension written in
> JavaScrpit, using the workaround described at:
> https://developer.mozilla.org/en/Java_in_Firefox_Extensions
>
> But when I try to dump some debug messages by using Logger or
> System.out, nothing appears in the console of Firefox.
> What is a good way of recording log messages in JavaCode that is
> called from a Firefox extension?
>
> Just to be clear, what I mean by the console is the command-line
> window that shows up when you invoke firefox.exe with the "-console"
> option.
> I changed the value of "browser.dom.window.dump.enabled"  to true, and
> I can successfully log messages by dump() in JavaScript code.
>    

The Java System.out messages will appear in the Java Console, but yes,
not Firefox's own. You can enable the Java Console in Windows by Control
Panel->Java->Advanced->Java Console->Show console.

Or, within JavaScript, you can use the output of a Java method called by
LiveConnect and send the result to dump() or to Firefox's own console
(Tools->Error Console):

function logc (msg) {
     var consoleServ =
Components.classes['@mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleService);
     consoleServ.logStringMessage(msg);
}

best wishes,
Brett
_______________________________________________
dev-tech-java mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-java