Closed Bug 1293700 Opened 5 years ago Closed 5 years ago

Add console object to WebExtension internals

Categories

(WebExtensions :: Untriaged, defect)

51 Branch
defect
Not set
normal

Tracking

(firefox51 fixed)

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: kmag, Assigned: kmag)

Details

Attachments

(1 file)

This is a common issue for new contributors. They've come to expect console.log to be available for debugging, and have to ask about alternatives when it isn't. We should just provide a console object to make it easier on them.
Comment on attachment 8779483 [details]
Bug 1293700: Make console object available to WebExtension internals.

https://reviewboard.mozilla.org/r/70460/#review68054

This looks good, but for my own background, why ConsoleAPI.jsm over Log.jsm?
Attachment #8779483 - Flags: review?(aswan) → review+
Do we want the emitted logs to be visible in the WebExtension DevTools window?
Flags: needinfo?(kmaglione+bmo)
(In reply to Andrew Swan [:aswan] from comment #2)
> This looks good, but for my own background, why ConsoleAPI.jsm over Log.jsm?

This is just to make things easier for contributors. We still 
have an ESLint rule to prevent code that uses the console object 
from landing.

(In reply to Luca Greco [:rpl] from comment #3)
> Do we want the emitted logs to be visible in the WebExtension DevTools
> window?

I don't really have an opinion either way.
Flags: needinfo?(kmaglione+bmo)
Sounds good, in that case I think that having the logs visible in the Browser Console / Browser Toolbox is good enough for this use case.
(In reply to Kris Maglione [:kmag] from comment #4)
> This is just to make things easier for contributors. We still 
> have an ESLint rule to prevent code that uses the console object 
> from landing.

I think creating a logger object would be just as easy for contributors and also let us actually start to put in some permanent logging.
(In reply to Andrew Swan [:aswan] from comment #6)
> (In reply to Kris Maglione [:kmag] from comment #4)
> > This is just to make things easier for contributors. We still 
> > have an ESLint rule to prevent code that uses the console object 
> > from landing.
> 
> I think creating a logger object would be just as easy for contributors and
> also let us actually start to put in some permanent logging.

People tend to expect the console object to be there, and to use it for debugging. It's also generally much more useful for debugging than a logger object, since you can interactively inspect the objects that it logs in the console.
https://hg.mozilla.org/integration/mozilla-inbound/rev/7fe7a701838bf714e61072cd618b3c5c93c85eae
Bug 1293700: Make console object available to WebExtension internals. r=aswan
https://hg.mozilla.org/mozilla-central/rev/7fe7a701838b
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.