3 <% log_history = stderr_log_history([@object.uuid]) %>
5 <div id="event_log_div"
6 class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window"
7 data-object-uuid="<%= @object.uuid %>"
8 ><%= log_history.join("\n") %></div>
10 <%# Applying a long throttle suppresses the auto-refresh of this
11 partial that would normally be triggered by arv-log-event. %>
12 <div class="arv-log-refresh-control"
13 data-load-throttle="86486400000" <%# 1001 nights %>
21 var logViewer = new List('log-viewer', {
22 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
26 logViewer.page_offset = 0;
27 logViewer.on("updated", function() { updatePaging(".log-viewer-paging", logViewer, pagesize) } );
28 $(".log-viewer-page-up").on("click", function() { prevPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
29 $(".log-viewer-page-down").on("click", function() { nextPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
31 var taskState = newTaskState();
33 var makeFilter = function() {
35 $(".toggle-filter, .radio-filter").each(function(i, e) {
37 pass.push(e.id.substr(5));
41 return (function(item) {
43 if (item.values().taskid !== "") {
45 if (pass[a] == "all-tasks") { v = true; }
46 else if (pass[a] == "successful-tasks" && taskState[item.values().taskid].outcome == "success") { v = true; }
47 else if (pass[a] == "failed-tasks" && taskState[item.values().taskid].outcome == "failure") { v = true; }
53 if (pass[a] == item.values().type) { return v; }
60 <% logcollection = Collection.find @object.log %>
61 <% if logcollection %>
62 log_size = <%= logcollection.files[0][2] %>
63 log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
64 logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
65 $("#log-viewer-download-url").attr('href', logcollection_url);
66 $("#log-viewer-download-pane").show();
67 if (log_size > log_maxbytes) {
68 range_header = { 'Range': 'bytes=0-' + log_maxbytes };
72 $.ajax(logcollection_url, { headers: range_header }).
73 done(function(data, status, jqxhr) {
75 addToLogViewer(logViewer, data.split("\n"), taskState);
76 logViewer.filter(makeFilter());
77 content_range_hdr = jqxhr.getResponseHeader('Content-Range');
78 var v = content_range_hdr && content_range_hdr.match(/bytes \d+-(\d+)\/(.+)/);
79 short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]);
80 if (jqxhr.status == 206 && short_log) {
81 $("#log-viewer-overview").html(
82 '<p>Showing only ' + data.length + ' bytes of this log.' +
83 ' Timing information is unavailable since' +
84 ' the full log was not retrieved.</p>'
87 generateJobOverview("#log-viewer-overview", logViewer, taskState);
89 $("#log-viewer .spinner").detach();
91 fail(function(jqxhr, status, error) {
92 $("#log-viewer .spinner").detach();
96 <%# Live log loading not implemented yet. %>
99 $(".toggle-filter, .radio-filter").on("change", function() {
100 logViewer.filter(makeFilter());
103 $("#filter-all").on("click", function() {
104 $(".toggle-filter").each(function(i, f) { f.checked = true; });
105 logViewer.filter(makeFilter());
108 $("#filter-none").on("click", function() {
109 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
110 logViewer.filter(makeFilter());
113 $("#sort-by-time").on("change", function() {
114 logViewer.sort("id", {sortFunction: sortById});
117 $("#sort-by-task").on("change", function() {
118 logViewer.sort("taskid", {sortFunction: sortByTask});
121 $("#sort-by-node").on("change", function() {
122 logViewer.sort("node", {sortFunction: sortByNode});
125 $("#set-show-failed-only").on("click", function() {
126 $("#sort-by-task").prop("checked", true);
127 $("#show-failed-tasks").prop("checked", true);
128 $("#show-crunch").prop("checked", false);
129 $("#show-task-dispatch").prop("checked", true);
130 $("#show-script-print").prop("checked", true);
131 $("#show-crunchstat").prop("checked", false);
132 logViewer.filter(makeFilter());
133 logViewer.sort("taskid", {sortFunction: sortByTask});
140 <div id="log-viewer">
143 <p id="log-viewer-overview">
144 <% if !logcollection %>
145 The collection containing the job log was not found.
149 <p id="log-viewer-download-pane" style="display:none">
150 <a id="log-viewer-download-url" href="">Download the full log</a>
155 <span class="pull-right">
156 <% if @object.andand.tasks_summary.andand[:failed] and @object.tasks_summary[:failed] > 0 %>
157 <button id="set-show-failed-only" class="btn btn-danger">
158 Show failed task diagnostics only
162 <button id="filter-all" class="btn">
165 <button id="filter-none" class="btn">
171 <input class="search pull-right" style="margin-top: 1em" placeholder="Search" />
174 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
175 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
177 <div class="radio-inline log-viewer-button">
178 <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
181 <div class="radio-inline log-viewer-button">
182 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
187 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
188 <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="radio-filter"> Show all tasks</label>
190 <div class="radio-inline log-viewer-button">
191 <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only successful tasks</label>
193 <div class="radio-inline log-viewer-button">
194 <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only failed tasks</label>
199 <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
200 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch diagnostics</label>
202 <div class="checkbox-inline log-viewer-button">
203 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
205 <div class="checkbox-inline log-viewer-button">
206 <label><input id="show-task-print" type="checkbox" checked="true" class="toggle-filter"> Show task diagnostics</label>
208 <div class="checkbox-inline log-viewer-button">
209 <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
214 <div class="smart-scroll" data-smart-scroll-padding-bottom="50" style="margin-bottom: 0px">
215 <table class="log-viewer-table">
218 <th class="id" data-sort="id"></th>
219 <th class="timestamp" data-sort="timestamp">Timestamp</th>
220 <th class="node" data-sort="node">Node</th>
221 <th class="slot" data-sort="slot">Slot</th>
222 <th class="type" data-sort="type">Log type</th>
223 <th class="taskid" data-sort="taskid">Task</th>
224 <th class="message" data-sort="message">Message</th>
230 <td class="timestamp"></td>
231 <td class="node"></td>
232 <td class="slot"></td>
233 <td class="type"></td>
234 <td class="taskid"></td>
235 <td class="message"></td>
240 <% if @object.log and logcollection %>
241 <div class="spinner spinner-32px"></div>
246 <div class="log-viewer-paging-div" style="margin-bottom: -15px">
247 <a href="#" class="log-viewer-page-up"><span class='glyphicon glyphicon-arrow-up'></span></a>
248 <span class="log-viewer-paging"></span>
249 <a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>