3 <div id="log_graph_div"
4 class="arv-log-event-listener"
6 data-object-uuid="<%= @object.uuid %>"></div>
8 <div id="event_log_div"
9 class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window"
10 data-object-uuid="<%= @object.uuid %>"
11 ><%= @object.stderr_log_lines(Rails.configuration.running_job_log_records_to_fetch).join("\n") %>
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 %>
25 var logViewer = new List('log-viewer', {
26 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
30 logViewer.page_offset = 0;
31 logViewer.on("updated", function() { updatePaging(".log-viewer-paging", logViewer, pagesize) } );
32 $(".log-viewer-page-up").on("click", function() { prevPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
33 $(".log-viewer-page-down").on("click", function() { nextPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
35 var taskState = newTaskState();
37 var makeFilter = function() {
39 $(".toggle-filter, .radio-filter").each(function(i, e) {
41 pass.push(e.id.substr(5));
45 return (function(item) {
47 if (item.values().taskid !== "") {
49 if (pass[a] == "all-tasks") { v = true; }
50 else if (pass[a] == "successful-tasks" && taskState[item.values().taskid].outcome == "success") { v = true; }
51 else if (pass[a] == "failed-tasks" && taskState[item.values().taskid].outcome == "failure") { v = true; }
57 if (pass[a] == item.values().type) { return v; }
63 <% if @object.log and !@object.log.empty? %>
64 <% logcollection = Collection.find @object.log %>
65 <% if logcollection %>
66 var log_size = <%= logcollection.files[0][2] %>
67 var log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
68 var logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
69 $("#log-viewer-download-url").attr('href', logcollection_url);
70 $("#log-viewer-download-pane").show();
72 if (log_size > log_maxbytes) {
73 headers['Range'] = 'bytes=0-' + log_maxbytes;
75 var ajax_opts = { dataType: 'text', headers: headers };
79 $.ajax(logcollection_url, ajax_opts).done(done).fail(fail);
81 function done(data, status, jqxhr) {
82 if (jqxhr.getResponseHeader('Content-Type').indexOf('application/json') === 0) {
83 // The browser won't allow a redirect-with-cookie response
84 // because keep-web isn't same-origin with us. Instead, we
85 // assure keep-web it's OK to respond with the content
86 // immediately by setting the token in the request body
87 // instead and adding disposition=attachment.
88 logcollection_url = JSON.parse(data).href;
89 var queryAt = logcollection_url.indexOf('?api_token=');
91 ajax_opts.method = 'POST';
93 api_token: logcollection_url.slice(queryAt+11),
94 disposition: 'attachment',
96 logcollection_url = logcollection_url.slice(0, queryAt);
101 addToLogViewer(logViewer, data.split("\n"), taskState);
102 logViewer.filter(makeFilter());
103 content_range_hdr = jqxhr.getResponseHeader('Content-Range');
104 var v = content_range_hdr && content_range_hdr.match(/bytes \d+-(\d+)\/(.+)/);
105 short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]);
106 if (jqxhr.status == 206 && short_log) {
107 $("#log-viewer-overview").html(
108 '<p>Showing only ' + data.length + ' bytes of this log.' +
109 ' Timing information is unavailable since' +
110 ' the full log was not retrieved.</p>'
113 generateJobOverview("#log-viewer-overview", logViewer, taskState);
115 $("#log-viewer .spinner").detach();
117 function fail(jqxhr, status, error) {
118 // TODO: tell the user about the error
119 console.log('load_log failed: status='+status+' error='+error);
120 $("#log-viewer .spinner").detach();
124 <%# Live log loading not implemented yet. %>
127 $(".toggle-filter, .radio-filter").on("change", function() {
128 logViewer.filter(makeFilter());
131 $("#filter-all").on("click", function() {
132 $(".toggle-filter").each(function(i, f) { f.checked = true; });
133 logViewer.filter(makeFilter());
136 $("#filter-none").on("click", function() {
137 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
138 logViewer.filter(makeFilter());
141 $("#sort-by-time").on("change", function() {
142 logViewer.sort("id", {sortFunction: sortById});
145 $("#sort-by-task").on("change", function() {
146 logViewer.sort("taskid", {sortFunction: sortByTask});
149 $("#sort-by-node").on("change", function() {
150 logViewer.sort("node", {sortFunction: sortByNode});
153 $("#set-show-failed-only").on("click", function() {
154 $("#sort-by-task").prop("checked", true);
155 $("#show-failed-tasks").prop("checked", true);
156 $("#show-crunch").prop("checked", false);
157 $("#show-task-dispatch").prop("checked", true);
158 $("#show-script-print").prop("checked", true);
159 $("#show-crunchstat").prop("checked", false);
160 logViewer.filter(makeFilter());
161 logViewer.sort("taskid", {sortFunction: sortByTask});
168 <div id="log-viewer">
171 <p id="log-viewer-overview">
172 <% if !logcollection %>
173 The collection containing the job log was not found.
177 <p id="log-viewer-download-pane" style="display:none">
178 <a id="log-viewer-download-url" href="">Download the full log</a>
183 <span class="pull-right">
184 <% if @object.andand.tasks_summary.andand[:failed] and @object.tasks_summary[:failed] > 0 %>
185 <button id="set-show-failed-only" class="btn btn-danger">
186 Show failed task diagnostics only
190 <button id="filter-all" class="btn">
193 <button id="filter-none" class="btn">
199 <input class="search pull-right" style="margin-top: 1em" placeholder="Search" />
202 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
203 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
205 <div class="radio-inline log-viewer-button">
206 <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
209 <div class="radio-inline log-viewer-button">
210 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
215 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
216 <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="radio-filter"> Show all tasks</label>
218 <div class="radio-inline log-viewer-button">
219 <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only successful tasks</label>
221 <div class="radio-inline log-viewer-button">
222 <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only failed tasks</label>
227 <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
228 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch diagnostics</label>
230 <div class="checkbox-inline log-viewer-button">
231 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
233 <div class="checkbox-inline log-viewer-button">
234 <label><input id="show-task-print" type="checkbox" checked="true" class="toggle-filter"> Show task diagnostics</label>
236 <div class="checkbox-inline log-viewer-button">
237 <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
242 <div class="smart-scroll" data-smart-scroll-padding-bottom="50" style="margin-bottom: 0px">
243 <table class="log-viewer-table">
246 <th class="id" data-sort="id"></th>
247 <th class="timestamp" data-sort="timestamp">Timestamp</th>
248 <th class="node" data-sort="node">Node</th>
249 <th class="slot" data-sort="slot">Slot</th>
250 <th class="type" data-sort="type">Log type</th>
251 <th class="taskid" data-sort="taskid">Task</th>
252 <th class="message" data-sort="message">Message</th>
258 <td class="timestamp"></td>
259 <td class="node"></td>
260 <td class="slot"></td>
261 <td class="type"></td>
262 <td class="taskid"></td>
263 <td class="message"></td>
268 <% if @object.log and logcollection %>
269 <div class="spinner spinner-32px"></div>
274 <div class="log-viewer-paging-div" style="margin-bottom: -15px">
275 <a href="#" class="log-viewer-page-up"><span class='glyphicon glyphicon-arrow-up'></span></a>
276 <span class="log-viewer-paging"></span>
277 <a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>