Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty console.log output for JavaScript objects #9322

Open
gordonbrander opened this issue Jan 14, 2016 · 9 comments
Open

Pretty console.log output for JavaScript objects #9322

gordonbrander opened this issue Jan 14, 2016 · 9 comments

Comments

@gordonbrander
Copy link

@gordonbrander gordonbrander commented Jan 14, 2016

Since Servo doesn't yet have devtools, we rely a lot on "printf-style debugging" for Browser.html (e.g. console.log).

Currently, console.log on an object results in [object Object], which is a bit opaque :). If we could serialize JavaScript objects before printing, it would make debugging web apps in Servo much easier.

cc @paulrouget @metajack

@metajack
Copy link
Contributor

@metajack metajack commented Jan 14, 2016

@jdm Could this be a good first bug for someone? What's the best path forward for this?

@jdm
Copy link
Member

@jdm jdm commented Jan 14, 2016

We should figure out what Firefox's algorithm is for prettifying JS objects and copy that.

@frewsxcv frewsxcv added the A-devtools label Jan 14, 2016
@paulrouget
Copy link
Contributor

@paulrouget paulrouget commented Jan 18, 2016

/cc @bgrins

@past
Copy link

@past past commented Jan 18, 2016

The Firefox console uses the Debugger API and the Remote Debugging Protocol actors to transfer information about JS objects. Take a look at the console API, the console actor and the client-side rendering for instance:

https://dxr.mozilla.org/mozilla-central/rev/0a4331e7d7ba21c3a54d9f17fb6ed1f42b7c29ec/dom/base/Console.cpp#1181
https://dxr.mozilla.org/mozilla-central/source/devtools/server/actors/webconsole.js#1578
https://dxr.mozilla.org/mozilla-central/source/devtools/client/webconsole/console-output.js#1372

I don't know how much of the RDP is implemented in Servo, but if it's not very far yet you may want to use something simpler in the meantime like serialization to and from JSON.

@jdm
Copy link
Member

@jdm jdm commented Jan 18, 2016

Yeah, we have zero support for the debugging API at the moment.

@bgrins
Copy link
Contributor

@bgrins bgrins commented Jan 19, 2016

There's also a simple log/stringification function used by Console.jsm here which is passed into dump(): https://dxr.mozilla.org/mozilla-central/source/toolkit/modules/Console.jsm#180

@jdm
Copy link
Member

@jdm jdm commented Jan 19, 2016

Ick, that's going to be really awful to translate into JSAPI calls.

@nox nox self-assigned this Mar 25, 2016
@nox
Copy link
Member

@nox nox commented Mar 30, 2016

I think we should rather transcribe https://dxr.mozilla.org/mozilla-central/source/toolkit/modules/Console.jsm#118 instead of the multiline one.

@nox nox removed the C-assigned label May 18, 2016
@nox nox removed their assignment May 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.