Closed Bug 639800 Opened 14 years ago Closed 9 years ago

Web Console should pretty-print stacks

Categories

(DevTools :: Console, enhancement, P1)

enhancement

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: wes, Unassigned)

References

Details

(Whiteboard: [console-2][polish-backlog])

I'm not sure exactly what either the API or the GUI should look like, but developers like me could really benefit from a way to pretty-print JS stacks. It's important that the API not require an Error object, since I want to use serialized stacks from other contexts (in particular, stacks generated on the server-side). Maybe an API like this? console.logException(label, stack); would put the label in the console, with a little arrow to the left of it, and when you click on the arrow the stack is shown, pretty-printed. So, a call like this would make sense in the console: try { foo } catch(e) { console.logException(e.name + ": " + e.message + " at " + e.fileName + ":" + e.lineNumber, e.stack); }
Thanks for filing this, Wes. Based on your description in IRC I was under the impression you were looking for something that could pretty-print any arbitrary JSON string in the console. Maybe you want a console.logJSON(label, jsonString)?
I think we can detect that there is an exception being logged - in which case we can pass it off to a prettyPrint function.
Whiteboard: [console-2]
robcee -- I was thinking specifically of stacks, although pretty-printing JSON objects would be useful, too (the inspector handles actual objects okay). ddahl - while detecting that we are logging an exception and pretty printing it would be extremely useful, there are use-cases where you can't robustly detect it; this is why I suggested a specialized API. These cases involve situations where the exception object has already been serialized before it is dumped to the console. This can happen when the error is remote and communicated to the web front-end via JSON IPC. "Remote" could be another window, some kind of future sandbox, a worker thread, or a server-side process (my application).
triage. Filter on PINKISBEAUTIFUL
Component: Developer Tools → Developer Tools: Console
Priority: -- → P3
Whiteboard: [console-2] → [console-2][devedition-40]
Priority: P3 → P1
Whiteboard: [console-2][devedition-40] → [console-2][polish-backlog]
Jeff, does console.trace() and/or console.error() solve this use case? I'm not sure I understand exactly what this bug is requesting.. maybe you do since you did the last triage.
Flags: needinfo?(jgriffiths)
(In reply to Brian Grinstead [:bgrins] from comment #5) > Jeff, does console.trace() and/or console.error() solve this use case? I'm > not sure I understand exactly what this bug is requesting.. maybe you do > since you did the last triage. Yup, thanks for the nudge.
Status: NEW → RESOLVED
Closed: 9 years ago
Flags: needinfo?(jgriffiths)
Resolution: --- → WORKSFORME
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.