Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upPretty console.log output for JavaScript objects #9322
Comments
|
@jdm Could this be a good first bug for someone? What's the best path forward for this? |
|
We should figure out what Firefox's algorithm is for prettifying JS objects and copy that. |
|
/cc @bgrins |
|
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 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. |
|
Yeah, we have zero support for the debugging API at the moment. |
|
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 |
|
Ick, that's going to be really awful to translate into JSAPI calls. |
|
I think we should rather transcribe https://dxr.mozilla.org/mozilla-central/source/toolkit/modules/Console.jsm#118 instead of the multiline one. |
Since Servo doesn't yet have devtools, we rely a lot on "printf-style debugging" for Browser.html (e.g.
console.log).Currently,
console.logon 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