Make the global 'console' object send messages to both the command line and Error Console



8 years ago
8 years ago


(Reporter: jwatt, Assigned: adw)



Firefox Tracking Flags

(Not tracked)



(1 attachment)



8 years ago
When I run my add-on using cfx from the command line I expect it to behave the same as it would when running it normally. It was therefore quite unexpected for me that messages I sent using the global 'console' object were not appearing in the Error Console. It was pointed out to me on IRC that this is because the messages go to the command line when Firefox is run from the command line.

To make add-ons behave the same as they would when running live, it would seem like the messages sent to the global 'console' object should be sent to the Error Console as well as the command line (a suggestion by myk).
Yup, I absolutely agree.  It's great that the messages get sent to the terminal, since that makes it easier for developers to debug their addons, but they should also get sent to the Error Console, so the behavior of the addon within Firefox is the same as it will be when it is being used by a user.
Priority: -- → P3
Target Milestone: --- → 1.0

Comment 2

8 years ago
Created attachment 539616 [details] [diff] [review]

This should do it...  The forsaken console dump function, in addition to logging to the console service, also does a standard dump.

I ran into a problem with the test harness.  It prints everything that goes through nsIConsoleService.  Since this patch changes the default print function to log to the console, the result is endless recursion.  (It's actually not endless since stack depth is clamped by the JS engine, I think.)  So I modified the test harness to print only nsIScriptErrors.  That breaks the recursion because the default print function just logs ordinary messages to the console and not nsIScriptErrors.  Since ordinary messages ought not indicate error, this seems reasonable anyway.  (But note bug 664518.)
Attachment #539616 - Flags: review?(myk)
(automatic reprioritization of 1.0 bugs)
Priority: P3 → P2
Target Milestone: 1.0 → 1.1
Comment on attachment 539616 [details] [diff] [review]

Looks good, seems to work fine, r=myk.
Attachment #539616 - Flags: review?(myk) → review+

Comment 5

8 years ago
Assignee: nobody → adw
Last Resolved: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.