Commit 76369e5cc67f27d1f5c96269f16cce604f2e8e71
1 parent
d69719a0
Exists in
master
and in
1 other branch
Hide large segments of external files in backtraces, centred around in-app files…
…. Expand external traces when clicking [...] button.
Showing
5 changed files
with
79 additions
and
11 deletions
Show diff stats
app/assets/javascripts/errbit.js
@@ -95,4 +95,10 @@ $(function() { | @@ -95,4 +95,10 @@ $(function() { | ||
95 | } | 95 | } |
96 | 96 | ||
97 | init(); | 97 | init(); |
98 | + | ||
99 | + // Show external backtrace lines when clicking separator | ||
100 | + $('td.backtrace_separator span').live('click', function(){ | ||
101 | + $('tr.hidden_external_backtrace').removeClass('hidden_external_backtrace'); | ||
102 | + $('td.backtrace_separator').hide(); | ||
103 | + }); | ||
98 | }); | 104 | }); |
app/assets/stylesheets/errbit.css
@@ -762,6 +762,26 @@ table.backtrace td.line.in-app { | @@ -762,6 +762,26 @@ table.backtrace td.line.in-app { | ||
762 | table.backtrace td.line.in-app .file { color: #2AEB2E; } | 762 | table.backtrace td.line.in-app .file { color: #2AEB2E; } |
763 | table.backtrace td.line.in-app .method { color: #2ACB2E; } | 763 | table.backtrace td.line.in-app .method { color: #2ACB2E; } |
764 | 764 | ||
765 | +/* External backtrace classes and separators */ | ||
766 | +table.backtrace tr.hidden_external_backtrace { | ||
767 | + display: none; | ||
768 | +} | ||
769 | +table.backtrace td.backtrace_separator span { | ||
770 | + cursor: pointer; | ||
771 | + display: inline-block; | ||
772 | + font-size: 17px; | ||
773 | + font-weight: bold; | ||
774 | + padding: 0px 11px 5px; | ||
775 | + margin: 4px 0; | ||
776 | + background-color: #444444; | ||
777 | + border: 1px solid #555555; | ||
778 | +} | ||
779 | +table.backtrace td.backtrace_separator span:hover { | ||
780 | + background-color: #666666; | ||
781 | + border: 1px solid #777777; | ||
782 | +} | ||
783 | + | ||
784 | + | ||
765 | 785 | ||
766 | /* Extra empty rows at top and bottom of table */ | 786 | /* Extra empty rows at top and bottom of table */ |
767 | table.backtrace tr.padding th, table.backtrace tr.padding td { | 787 | table.backtrace tr.padding th, table.backtrace tr.padding td { |
app/helpers/notices_helper.rb
@@ -30,5 +30,38 @@ module NoticesHelper | @@ -30,5 +30,38 @@ module NoticesHelper | ||
30 | href = app.issue_tracker.url_to_file(file_path, line['number']) | 30 | href = app.issue_tracker.url_to_file(file_path, line['number']) |
31 | link_to(text || file_name, href, :target => '_blank') | 31 | link_to(text || file_name, href, :target => '_blank') |
32 | end | 32 | end |
33 | + | ||
34 | + # Group lines into sections of in-app files and external files | ||
35 | + # (An implementation of Enumerable#chunk so we don't break 1.8.7 support.) | ||
36 | + def grouped_lines(lines) | ||
37 | + line_groups = [] | ||
38 | + lines.each do |line| | ||
39 | + in_app = Notice.in_app_backtrace_line?(line) | ||
40 | + if line_groups.last && line_groups.last[0] == in_app | ||
41 | + line_groups.last[1] << line | ||
42 | + else | ||
43 | + line_groups << [in_app, [line]] | ||
44 | + end | ||
45 | + end | ||
46 | + line_groups | ||
47 | + end | ||
48 | + | ||
49 | + def rows_for_line_segment(lines, start, length, row_class = nil) | ||
50 | + html = "" | ||
51 | + lines[start, length].each do |line| | ||
52 | + html << render(:partial => "notices/backtrace_line", :locals => {:line => line, :row_class => row_class}) | ||
53 | + end | ||
54 | + html.html_safe | ||
55 | + end | ||
56 | + | ||
57 | + def path_for_backtrace_line(line) | ||
58 | + path = File.dirname(line['file']) | ||
59 | + path == "." ? "" : path + '/' | ||
60 | + end | ||
61 | + | ||
62 | + def file_for_backtrace_line(line) | ||
63 | + file = File.basename(line['file']) | ||
64 | + line['number'].present? ? "#{file}:#{line['number']}" : file | ||
65 | + end | ||
33 | end | 66 | end |
34 | 67 |
app/views/notices/_backtrace.html.haml
1 | .window | 1 | .window |
2 | %table.backtrace | 2 | %table.backtrace |
3 | - - lines.each do |line| | ||
4 | - - path = File.dirname(line['file']) | ||
5 | - - path = path == "." ? "" : path + '/' | ||
6 | - - file = File.basename(line['file']) | ||
7 | - - file = "#{file}:#{line['number']}" unless line['number'].blank? | ||
8 | - %tr | ||
9 | - %td.line{:class => (Notice.in_app_backtrace_line?(line) ? 'in-app' : nil)} | ||
10 | - %span.path>= path | ||
11 | - %span.file= link_to_source_file(@app, line, file).html_safe | ||
12 | - → | ||
13 | - %span.method= line['method'] | 3 | + -# Group lines into internal / external so we can toggle the external backtrace |
4 | + -# Includes a margin of x lines that are not toggled. | ||
5 | + - external_margin = 3 | ||
6 | + - grouped_lines(lines).each do |in_app, line_group| | ||
7 | + - if !in_app && line_group.size > 6 | ||
8 | + = rows_for_line_segment(line_group, 0, external_margin) | ||
9 | + = rows_for_line_segment(line_group, 2, line_group.size - (external_margin * 2), 'hidden_external_backtrace') | ||
10 | + %tr | ||
11 | + %td.line.backtrace_separator | ||
12 | + %span ... | ||
13 | + = rows_for_line_segment(line_group, external_margin * -1, external_margin) | ||
14 | 14 | ||
15 | + - else | ||
16 | + - line_group.each do |line| | ||
17 | + = render :partial => "notices/backtrace_line", :locals => {:line => line} |
@@ -0,0 +1,6 @@ | @@ -0,0 +1,6 @@ | ||
1 | +%tr{:class => defined?(row_class) ? row_class : nil} | ||
2 | + %td.line{:class => (Notice.in_app_backtrace_line?(line) ? 'in-app' : nil)} | ||
3 | + %span.path>= path_for_backtrace_line(line) | ||
4 | + %span.file= link_to_source_file(@app, line, file_for_backtrace_line(line)).html_safe | ||
5 | + → | ||
6 | + %span.method= line['method'] |