3 <div id="log_graph_div"
4 class="arv-log-event-listener"
5 data-object-uuid="<%= @object.uuid %>"></div>
7 <% log_history = stderr_log_history([@object.uuid]) %>
9 <div id="event_log_div"
10 class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window"
11 data-object-uuid="<%= @object.uuid %>"
12 ><%= log_history.join("\n") %></div>
14 <%# Applying a long throttle suppresses the auto-refresh of this
15 partial that would normally be triggered by arv-log-event. %>
16 <div class="arv-log-refresh-control"
17 data-load-throttle="86486400000" <%# 1001 nights %>
20 <%= javascript_tag do %>
21 window.jobGraphData = [];
22 window.jobGraphSeries = [];
23 window.jobGraphMaxima = {};
24 <% stderr_log_records([@object.uuid],[['properties','~','crunchstat:.*-- interval']])
25 .each.with_index do |log_record, index| %>
26 var logLine = '<%=j log_record.properties[:text] %>';
27 processLogLineForChart( logLine );
29 window.jobGraph = Morris.Line({
30 element: 'log_graph_div',
33 ykeys: jobGraphSeries,
34 labels: jobGraphSeries
43 var logViewer = new List('log-viewer', {
44 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
48 logViewer.page_offset = 0;
49 logViewer.on("updated", function() { updatePaging(".log-viewer-paging", logViewer, pagesize) } );
50 $(".log-viewer-page-up").on("click", function() { prevPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
51 $(".log-viewer-page-down").on("click", function() { nextPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
53 var taskState = newTaskState();
55 var makeFilter = function() {
57 $(".toggle-filter, .radio-filter").each(function(i, e) {
59 pass.push(e.id.substr(5));
63 return (function(item) {
65 if (item.values().taskid !== "") {
67 if (pass[a] == "all-tasks") { v = true; }
68 else if (pass[a] == "successful-tasks" && taskState[item.values().taskid].outcome == "success") { v = true; }
69 else if (pass[a] == "failed-tasks" && taskState[item.values().taskid].outcome == "failure") { v = true; }
75 if (pass[a] == item.values().type) { return v; }
82 <% logcollection = Collection.find @object.log %>
83 <% if logcollection %>
84 log_size = <%= logcollection.files[0][2] %>
85 log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
86 logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
87 $("#log-viewer-download-url").attr('href', logcollection_url);
88 $("#log-viewer-download-pane").show();
89 if (log_size > log_maxbytes) {
90 range_header = { 'Range': 'bytes=0-' + log_maxbytes };
94 $.ajax(logcollection_url, { headers: range_header }).
95 done(function(data, status, jqxhr) {
97 addToLogViewer(logViewer, data.split("\n"), taskState);
98 logViewer.filter(makeFilter());
99 content_range_hdr = jqxhr.getResponseHeader('Content-Range');
100 var v = content_range_hdr && content_range_hdr.match(/bytes \d+-(\d+)\/(.+)/);
101 short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]);
102 if (jqxhr.status == 206 && short_log) {
103 $("#log-viewer-overview").html(
104 '<p>Showing only ' + data.length + ' bytes of this log.' +
105 ' Timing information is unavailable since' +
106 ' the full log was not retrieved.</p>'
109 generateJobOverview("#log-viewer-overview", logViewer, taskState);
111 $("#log-viewer .spinner").detach();
113 fail(function(jqxhr, status, error) {
114 $("#log-viewer .spinner").detach();
118 <%# Live log loading not implemented yet. %>
121 $(".toggle-filter, .radio-filter").on("change", function() {
122 logViewer.filter(makeFilter());
125 $("#filter-all").on("click", function() {
126 $(".toggle-filter").each(function(i, f) { f.checked = true; });
127 logViewer.filter(makeFilter());
130 $("#filter-none").on("click", function() {
131 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
132 logViewer.filter(makeFilter());
135 $("#sort-by-time").on("change", function() {
136 logViewer.sort("id", {sortFunction: sortById});
139 $("#sort-by-task").on("change", function() {
140 logViewer.sort("taskid", {sortFunction: sortByTask});
143 $("#sort-by-node").on("change", function() {
144 logViewer.sort("node", {sortFunction: sortByNode});
147 $("#set-show-failed-only").on("click", function() {
148 $("#sort-by-task").prop("checked", true);
149 $("#show-failed-tasks").prop("checked", true);
150 $("#show-crunch").prop("checked", false);
151 $("#show-task-dispatch").prop("checked", true);
152 $("#show-script-print").prop("checked", true);
153 $("#show-crunchstat").prop("checked", false);
154 logViewer.filter(makeFilter());
155 logViewer.sort("taskid", {sortFunction: sortByTask});
162 <div id="log-viewer">
165 <p id="log-viewer-overview">
166 <% if !logcollection %>
167 The collection containing the job log was not found.
171 <p id="log-viewer-download-pane" style="display:none">
172 <a id="log-viewer-download-url" href="">Download the full log</a>
177 <span class="pull-right">
178 <% if @object.andand.tasks_summary.andand[:failed] and @object.tasks_summary[:failed] > 0 %>
179 <button id="set-show-failed-only" class="btn btn-danger">
180 Show failed task diagnostics only
184 <button id="filter-all" class="btn">
187 <button id="filter-none" class="btn">
193 <input class="search pull-right" style="margin-top: 1em" placeholder="Search" />
196 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
197 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
199 <div class="radio-inline log-viewer-button">
200 <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
203 <div class="radio-inline log-viewer-button">
204 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
209 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
210 <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="radio-filter"> Show all tasks</label>
212 <div class="radio-inline log-viewer-button">
213 <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only successful tasks</label>
215 <div class="radio-inline log-viewer-button">
216 <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only failed tasks</label>
221 <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
222 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch diagnostics</label>
224 <div class="checkbox-inline log-viewer-button">
225 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
227 <div class="checkbox-inline log-viewer-button">
228 <label><input id="show-task-print" type="checkbox" checked="true" class="toggle-filter"> Show task diagnostics</label>
230 <div class="checkbox-inline log-viewer-button">
231 <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
236 <div class="smart-scroll" data-smart-scroll-padding-bottom="50" style="margin-bottom: 0px">
237 <table class="log-viewer-table">
240 <th class="id" data-sort="id"></th>
241 <th class="timestamp" data-sort="timestamp">Timestamp</th>
242 <th class="node" data-sort="node">Node</th>
243 <th class="slot" data-sort="slot">Slot</th>
244 <th class="type" data-sort="type">Log type</th>
245 <th class="taskid" data-sort="taskid">Task</th>
246 <th class="message" data-sort="message">Message</th>
252 <td class="timestamp"></td>
253 <td class="node"></td>
254 <td class="slot"></td>
255 <td class="type"></td>
256 <td class="taskid"></td>
257 <td class="message"></td>
262 <% if @object.log and logcollection %>
263 <div class="spinner spinner-32px"></div>
268 <div class="log-viewer-paging-div" style="margin-bottom: -15px">
269 <a href="#" class="log-viewer-page-up"><span class='glyphicon glyphicon-arrow-up'></span></a>
270 <span class="log-viewer-paging"></span>
271 <a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>