1 <%# Copyright (C) The Arvados Authors. All rights reserved.
3 SPDX-License-Identifier: AGPL-3.0 %>
7 <div id="log_graph_div"
8 class="arv-log-event-listener"
10 data-object-uuid="<%= @object.uuid %>"></div>
12 <pre id="event_log_div"
13 class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window"
14 data-object-uuid="<%= @object.uuid %>"
15 ><%= @object.stderr_log_lines(Rails.configuration.running_job_log_records_to_fetch).join("\n") %>
18 <%# Applying a long throttle suppresses the auto-refresh of this
19 partial that would normally be triggered by arv-log-event. %>
20 <div class="arv-log-refresh-control"
21 data-load-throttle="86486400000" <%# 1001 nights %>
29 var logViewer = new List('log-viewer', {
30 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
34 logViewer.page_offset = 0;
35 logViewer.on("updated", function() { updatePaging(".log-viewer-paging", logViewer, pagesize) } );
36 $(".log-viewer-page-up").on("click", function() { prevPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
37 $(".log-viewer-page-down").on("click", function() { nextPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
39 var taskState = newTaskState();
41 var makeFilter = function() {
43 $(".toggle-filter, .radio-filter").each(function(i, e) {
45 pass.push(e.id.substr(5));
49 return (function(item) {
51 if (item.values().taskid !== "") {
53 if (pass[a] == "all-tasks") { v = true; }
54 else if (pass[a] == "successful-tasks" && taskState[item.values().taskid].outcome == "success") { v = true; }
55 else if (pass[a] == "failed-tasks" && taskState[item.values().taskid].outcome == "failure") { v = true; }
61 if (pass[a] == item.values().type) { return v; }
67 <% if @object.log and !@object.log.empty? %>
68 <% logcollection = Collection.find @object.log %>
69 <% if logcollection %>
70 var log_size = <%= logcollection.files[0][2] %>
71 var log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
72 var logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
73 $("#log-viewer-download-url").attr('href', logcollection_url);
74 $("#log-viewer-download-pane").show();
76 if (log_size > log_maxbytes) {
77 headers['Range'] = 'bytes=0-' + (log_maxbytes - 1);
79 var ajax_opts = { dataType: 'text', headers: headers };
83 $.ajax(logcollection_url, ajax_opts).done(done).fail(fail);
85 function done(data, status, jqxhr) {
86 if (jqxhr.getResponseHeader('Content-Type').indexOf('application/json') === 0) {
87 // The browser won't allow a redirect-with-cookie response
88 // because keep-web isn't same-origin with us. Instead, we
89 // assure keep-web it's OK to respond with the content
90 // immediately by setting the token in the request body
91 // instead and adding disposition=attachment.
92 logcollection_url = JSON.parse(data).href;
93 var queryAt = logcollection_url.indexOf('?api_token=');
95 ajax_opts.method = 'POST';
97 api_token: logcollection_url.slice(queryAt+11),
98 disposition: 'attachment',
100 logcollection_url = logcollection_url.slice(0, queryAt);
105 addToLogViewer(logViewer, data.split("\n"), taskState);
106 logViewer.filter(makeFilter());
107 content_range_hdr = jqxhr.getResponseHeader('Content-Range');
108 var v = content_range_hdr && content_range_hdr.match(/bytes \d+-(\d+)\/(.+)/);
109 short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]);
110 if (jqxhr.status == 206 && short_log) {
111 $("#log-viewer-overview").html(
112 '<p>Showing only ' + data.length + ' bytes of this log.' +
113 ' Timing information is unavailable since' +
114 ' the full log was not retrieved.</p>'
117 generateJobOverview("#log-viewer-overview", logViewer, taskState);
119 $("#log-viewer .spinner").detach();
121 function fail(jqxhr, status, error) {
122 // TODO: tell the user about the error
123 console.log('load_log failed: status='+status+' error='+error);
124 $("#log-viewer .spinner").detach();
128 <%# Live log loading not implemented yet. %>
131 $(".toggle-filter, .radio-filter").on("change", function() {
132 logViewer.filter(makeFilter());
135 $("#filter-all").on("click", function() {
136 $(".toggle-filter").each(function(i, f) { f.checked = true; });
137 logViewer.filter(makeFilter());
140 $("#filter-none").on("click", function() {
141 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
142 logViewer.filter(makeFilter());
145 $("#sort-by-time").on("change", function() {
146 logViewer.sort("id", {sortFunction: sortById});
149 $("#sort-by-task").on("change", function() {
150 logViewer.sort("taskid", {sortFunction: sortByTask});
153 $("#sort-by-node").on("change", function() {
154 logViewer.sort("node", {sortFunction: sortByNode});
157 $("#set-show-failed-only").on("click", function() {
158 $("#sort-by-task").prop("checked", true);
159 $("#show-failed-tasks").prop("checked", true);
160 $("#show-crunch").prop("checked", false);
161 $("#show-task-dispatch").prop("checked", true);
162 $("#show-script-print").prop("checked", true);
163 $("#show-crunchstat").prop("checked", false);
164 logViewer.filter(makeFilter());
165 logViewer.sort("taskid", {sortFunction: sortByTask});
172 <div id="log-viewer">
175 <p id="log-viewer-overview">
176 <% if !logcollection %>
177 The collection containing the job log was not found.
181 <p id="log-viewer-download-pane" style="display:none">
182 <a id="log-viewer-download-url" href="">Download the full log</a>
187 <span class="pull-right">
188 <% if @object.andand.tasks_summary.andand[:failed] and @object.tasks_summary[:failed] > 0 %>
189 <button id="set-show-failed-only" class="btn btn-danger">
190 Show failed task diagnostics only
194 <button id="filter-all" class="btn">
197 <button id="filter-none" class="btn">
203 <input class="search pull-right" style="margin-top: 1em" placeholder="Search" />
206 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
207 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
209 <div class="radio-inline log-viewer-button">
210 <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
213 <div class="radio-inline log-viewer-button">
214 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
219 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
220 <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="radio-filter"> Show all tasks</label>
222 <div class="radio-inline log-viewer-button">
223 <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only successful tasks</label>
225 <div class="radio-inline log-viewer-button">
226 <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only failed tasks</label>
231 <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
232 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch diagnostics</label>
234 <div class="checkbox-inline log-viewer-button">
235 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
237 <div class="checkbox-inline log-viewer-button">
238 <label><input id="show-task-print" type="checkbox" checked="true" class="toggle-filter"> Show task diagnostics</label>
240 <div class="checkbox-inline log-viewer-button">
241 <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
246 <div class="smart-scroll" data-smart-scroll-padding-bottom="50" style="margin-bottom: 0px">
247 <table class="log-viewer-table">
250 <th class="id" data-sort="id"></th>
251 <th class="timestamp" data-sort="timestamp">Timestamp</th>
252 <th class="node" data-sort="node">Node</th>
253 <th class="slot" data-sort="slot">Slot</th>
254 <th class="type" data-sort="type">Log type</th>
255 <th class="taskid" data-sort="taskid">Task</th>
256 <th class="message" data-sort="message">Message</th>
262 <td class="timestamp"></td>
263 <td class="node"></td>
264 <td class="slot"></td>
265 <td class="type"></td>
266 <td class="taskid"></td>
267 <td class="message"></td>
272 <% if @object.log and logcollection %>
273 <div class="spinner spinner-32px"></div>
278 <div class="log-viewer-paging-div" style="margin-bottom: -15px">
279 <a href="#" class="log-viewer-page-up"><span class='glyphicon glyphicon-arrow-up'></span></a>
280 <span class="log-viewer-paging"></span>
281 <a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>