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

Formatting of Stacktraces #25375

Closed
yurivish opened this issue Jan 3, 2018 · 9 comments
Closed

Formatting of Stacktraces #25375

yurivish opened this issue Jan 3, 2018 · 9 comments
Labels
domain:display and printing Aesthetics and correctness of printed representations of objects.

Comments

@yurivish
Copy link
Contributor

yurivish commented Jan 3, 2018

(Originally posted in a different issue; moved here at @KristofferC 's suggestion)

I've noticed that it often takes me a while to orient myself when viewing a stacktrace -- and that the time could potentially be saved were the information presented in a a slightly different way.

Here's a screenshot of an error traceback:

screenshot 2018-01-03 14 55 23

One main purpose of a traceback during interactive development is to focus the user's attention on what went wrong and where it did so. From that perspective, the first useful piece of information above is in the row labeled [2] -- once you've seen that and correlated it back to the source line, you can start to understand the rest of the traceback.

In that light, I'm wondering how difficult it would be to emphasize the paths or lines indicating "user code", so they can draw your eye first and give you the context you need to interpret the rest of the stack trace?

There are a number of circumstances where the distinction between "user" and "non-user" code is less clear, such as when doing package development, or testing at the REPL code written elsewhere, but if there are simple rules that would work the majority of the time... Even just highlighting the "topmost" (non-REPL-internal) user-written code would notably improve the debugging experience and save people a lot of time.

Also, the white ) seems superfluous to me -- it catches the eye and doesn't supply any new information. Maybe just highlight the function name instead?

@ararslan ararslan added the domain:display and printing Aesthetics and correctness of printed representations of objects. label Jan 3, 2018
@KristofferC
Copy link
Sponsor Member

The white ) highlights that the function signature is over and that the line info is about to start, so I kind of like that.

Highlighting the first non Base frame is something I have thought about (also xref KristofferC/OhMyREPL.jl#24), but not sure how it is best done. Perhaps bold all stackframes that are not in Base... Would need some experimenting to feel it out.

@c42f
Copy link
Member

c42f commented Jan 3, 2018

Another thing which might be useful would be to use the display width for intelligent wrapping when printing frames in a terminal. At the moment functions with lots of arguments just overflow the line and spill into the first column which can be confusing.

@antoine-levitt
Copy link
Contributor

Agreed that it would be very good to have this, see #22653.

@StefanKarpinski
Copy link
Sponsor Member

Slightly off-topic, but since we're interpreting debug/info/warn/error messages as markdown, would it make sense to print them wrapped and flowed like markdown output, taking into account the screen width? (Question for @c42f mainly, but @fredrikekre and @KristofferC also.)

@KristofferC
Copy link
Sponsor Member

It should be noted here that for the ConsoleLogger, the same backtrace filtering as the REPL does should likely be added which means that for this particular example only stackframe [1] and [2] would be visible.

@c42f
Copy link
Member

c42f commented Jan 5, 2018

@StefanKarpinski absolutely part of the plan, I may try this as part of #25370 (see also #25370 (comment) ). The tricky thing will be persuading the markdown formatter to do the right thing at the same time as adding some extra decorations.

@StefanKarpinski
Copy link
Sponsor Member

Not urgent, but will be nice in the fullness of time.

@pfitzseb
Copy link
Member

In that light, I'm wondering how difficult it would be to emphasize the paths or lines indicating "user code", so they can draw your eye first and give you the context you need to interpret the rest of the stack trace?

Just as a reference: In Juno we highlight stacktraces in three different shades -- lowest opacity for stuff in base (lower two lines) and highest for user files (not in a package and not in base):
image

This is obviously difficult to do in the REPL due to the color limitations imposed by some terminals (especially on windows).

@KristofferC
Copy link
Sponsor Member

Closing this based on the new stacktrace formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:display and printing Aesthetics and correctness of printed representations of objects.
Projects
None yet
Development

No branches or pull requests

7 participants