W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2013

Re: Standardizing console APIs: Where?

From: Thaddee Tyl <thaddee.tyl@gmail.com>
Date: Wed, 27 Feb 2013 22:09:24 +0100
Message-ID: <CAE3TfZOav9okgrzuaDJG1M+mVH-SjvzQMWAb+shtOaAo69=pDw@mail.gmail.com>
To: François REMY <francois.remy.dev@outlook.com>
Cc: Brian Kardell <bkardell@gmail.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>, es-discuss <es-discuss@mozilla.org>
On Wed, Feb 27, 2013 at 7:55 PM, François REMY
<francois.remy.dev@outlook.com> wrote:
>> In browsers, when logging an object, you can actually click on an arrow
>> to browse through all its properties.
>> Serializing the whole thing on every single console.log, when those
>> happen in a loop,
>> would make the debugging experience a nightmare, performance-wise.
>
> True but we may expect the string representation to be exact while the details are loaded when expanded only.

Immediate string conversion can still be costly (which is why Firefox
and Safari use a cache).
It is a matter of tradeoff.
Paste this in the developer console:

    (a=[], function() { for (var i=0 ; i<100000 ; i++) { a[0]=i;
console.log(a); } })()

When Chrome does console.log in a huge loop (which can happen by
accident), the tab and the whole DevTools are unresponsive.
When Firefox' DevTools does the same, you can interact with the page
(and the rest of the DevTools) quite fine.
(I'm running it in gmail right now, fwiw.)
I tried to make something as fast in Firefox' JSTerm add-on, but it
isn't as resilient.

> The clickable behavior is an extension to the Console API (which is text-only). I agree that this part should not be standardized.

What subset of <https://getfirebug.com/wiki/index.php/Console_API> do
you wish to standardize?
How would the standard require to process the following?

   console.log('%cThis is red text on a green background', 'color:red;
background-color:green');

Where do we draw the line?
Can the standard compete with Firebug's ad hoc description, if it is
but a subset?

Also, testing this standard is… hard.

> However, IE has a console.clear() function that I find useful, it should probably be standardized.

That, too, is in <https://getfirebug.com/wiki/index.php/Console_API>.

> BTW it should be noted that some browsers only enable logging on a page if the console window is open (or was opened at some point in the page lifetime). This is maybe a way to avoid the slow down that more powerful logging tools could cause.

Best effort. That's the spirit.
Received on Wednesday, 27 February 2013 21:09:52 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:09 UTC