Show More
@@ -50,7 +50,7 b' class ExceptionsTrackerView(BaseAppView)' | |||
|
50 | 50 | count +=1 |
|
51 | 51 | return count |
|
52 | 52 | |
|
53 | def get_all_exceptions(self, read_metadata=False, limit=None): | |
|
53 | def get_all_exceptions(self, read_metadata=False, limit=None, type_filter=None): | |
|
54 | 54 | exc_store_path = exc_tracking.get_exc_store() |
|
55 | 55 | exception_list = [] |
|
56 | 56 | |
@@ -59,7 +59,7 b' class ExceptionsTrackerView(BaseAppView)' | |||
|
59 | 59 | return val.split('_')[-1] |
|
60 | 60 | except Exception: |
|
61 | 61 | return 0 |
|
62 | count = 0 | |
|
62 | ||
|
63 | 63 | for fname in reversed(sorted(os.listdir(exc_store_path), key=key_sorter)): |
|
64 | 64 | |
|
65 | 65 | parts = fname.split('_', 2) |
@@ -83,13 +83,17 b' class ExceptionsTrackerView(BaseAppView)' | |||
|
83 | 83 | except Exception: |
|
84 | 84 | log.exception('Failed to read exc data from:{}'.format(full_path)) |
|
85 | 85 | pass |
|
86 | ||
|
87 | 86 | # convert our timestamp to a date obj, for nicer representation |
|
88 | 87 | exc['exc_utc_date'] = time_to_utcdatetime(exc['exc_timestamp']) |
|
88 | ||
|
89 | type_present = exc.get('exc_type') | |
|
90 | if type_filter: | |
|
91 | if type_present and type_present == type_filter: | |
|
92 | exception_list.append(exc) | |
|
93 | else: | |
|
89 | 94 | exception_list.append(exc) |
|
90 | 95 | |
|
91 | count += 1 | |
|
92 | if limit and count >= limit: | |
|
96 | if limit and len(exception_list) >= limit: | |
|
93 | 97 | break |
|
94 | 98 | return exception_list |
|
95 | 99 | |
@@ -103,8 +107,10 b' class ExceptionsTrackerView(BaseAppView)' | |||
|
103 | 107 | c = self.load_default_context() |
|
104 | 108 | c.active = 'exceptions_browse' |
|
105 | 109 | c.limit = safe_int(self.request.GET.get('limit')) or 50 |
|
110 | c.type_filter = self.request.GET.get('type_filter') | |
|
106 | 111 | c.next_limit = c.limit + 50 |
|
107 |
c.exception_list = self.get_all_exceptions( |
|
|
112 | c.exception_list = self.get_all_exceptions( | |
|
113 | read_metadata=True, limit=c.limit, type_filter=c.type_filter) | |
|
108 | 114 | c.exception_list_count = self.count_all_exceptions() |
|
109 | 115 | c.exception_store_dir = exc_tracking.get_exc_store() |
|
110 | 116 | return self._get_template_context(c) |
@@ -132,12 +138,20 b' class ExceptionsTrackerView(BaseAppView)' | |||
|
132 | 138 | def exception_delete_all(self): |
|
133 | 139 | _ = self.request.translate |
|
134 | 140 | c = self.load_default_context() |
|
141 | type_filter = self.request.POST.get('type_filter') | |
|
135 | 142 | |
|
136 | 143 | c.active = 'exceptions' |
|
137 | all_exc = self.get_all_exceptions() | |
|
138 |
exc_count = |
|
|
144 | all_exc = self.get_all_exceptions(read_metadata=bool(type_filter), type_filter=type_filter) | |
|
145 | exc_count = 0 | |
|
146 | ||
|
139 | 147 | for exc in all_exc: |
|
148 | if type_filter: | |
|
149 | if exc.get('exc_type') == type_filter: | |
|
140 | 150 | exc_tracking.delete_exception(exc['exc_id'], prefix=None) |
|
151 | exc_count += 1 | |
|
152 | else: | |
|
153 | exc_tracking.delete_exception(exc['exc_id'], prefix=None) | |
|
154 | exc_count += 1 | |
|
141 | 155 | |
|
142 | 156 | h.flash(_('Removed {} Exceptions').format(exc_count), category='success') |
|
143 | 157 | raise HTTPFound(h.route_path('admin_settings_exception_tracker')) |
@@ -6,18 +6,24 b'' | |||
|
6 | 6 | % if c.exception_list_count == 1: |
|
7 | 7 | ${_('There is {} stored exception.').format(c.exception_list_count)} |
|
8 | 8 | % else: |
|
9 | ${_('There are {} stored exceptions.').format(c.exception_list_count)} | |
|
9 | ${_('There are total {} stored exceptions.').format(c.exception_list_count)} | |
|
10 | 10 | % endif |
|
11 | <br/> | |
|
11 | 12 | ${_('Store directory')}: ${c.exception_store_dir} |
|
12 | 13 | |
|
13 | 14 | ${h.secure_form(h.route_path('admin_settings_exception_tracker_delete_all'), request=request)} |
|
14 | 15 | <div style="margin: 0 0 20px 0" class="fake-space"></div> |
|
15 | ||
|
16 | <input type="hidden" name="type_filter", value="${c.type_filter}"> | |
|
16 | 17 | <div class="field"> |
|
17 | 18 | <button class="btn btn-small btn-danger" type="submit" |
|
18 | 19 | onclick="return confirm('${_('Confirm to delete all exceptions')}');"> |
|
19 | 20 | <i class="icon-remove-sign"></i> |
|
21 | % if c.type_filter: | |
|
22 | ${_('Delete All `{}`').format(c.type_filter)} | |
|
23 | % else: | |
|
20 | 24 | ${_('Delete All')} |
|
25 | % endif | |
|
26 | ||
|
21 | 27 | </button> |
|
22 | 28 | </div> |
|
23 | 29 | |
@@ -48,7 +54,9 b'' | |||
|
48 | 54 | <td><a href="${h.route_path('admin_settings_exception_tracker_show', exception_id=tb['exc_id'])}"><code>${tb['exc_id']}</code></a></td> |
|
49 | 55 | <td>${h.format_date(tb['exc_utc_date'])}</td> |
|
50 | 56 | <td>${tb['app_type']}</td> |
|
51 |
<td> |
|
|
57 | <td> | |
|
58 | <a href="${h.current_route_path(request, type_filter=tb['exc_type'])}">${tb['exc_type']}</a> | |
|
59 | </td> | |
|
52 | 60 | </tr> |
|
53 | 61 | <% cnt -=1 %> |
|
54 | 62 | % endfor |
General Comments 0
You need to be logged in to leave comments.
Login now