-<script>
-
-function addToLogViewer(logViewer, lines) {
- var re = /((\d\d\d\d)-(\d\d)-(\d\d))_((\d\d):(\d\d):(\d\d)) ([a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}) (\d+) (\d+)? (.*)/;
- for (var a in lines) {
- var v = lines[a].match(re);
- if (v != null) {
- v11 = v[11];
- if (typeof v[11] === 'undefined') {
- v11 = ' ';
- }
-
- var message = v[12];
- var type = "";
- if (v11 != ' ') {
- if (/^stderr /.test(message)) {
- type = "task-output";
- } else {
- type = "task-dispatch";
- }
- } else {
- if (/^status: /.test(message)) {
- type = "job-progress";
- } else {
- type = "crunch";
- }
- }
+<% if !@object.log %>
- logViewer.add({
- id: logViewer.items.length,
- timestamp: v[1] + " " + v[5],
- taskid: v11,
- message: message,
- type: type
- });
+<% log_history = stderr_log_history([@object.uuid]) %>
+<div class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window" id="pipeline_event_log_div" data-object-uuids="<%= @object.uuid %>">
+ <% log_history.each do |entry| %>
+ <%=entry%><br/>
+ <% end %>
+</div>
- } else {
- console.log("Did not parse: " + lines[a]);
- }
- }
- logViewer.update();
-}
+<% else %>
+<script>
(function() {
+var pagesize = 1000;
var logViewer = new List('log-viewer', {
- valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type']
+ valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
+ page: pagesize
});
+logViewer.page_offset = 0;
+logViewer.on("updated", function() { updatePaging(".log-viewer-paging", logViewer, pagesize) } );
+$(".log-viewer-page-up").on("click", function() { prevPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
+$(".log-viewer-page-down").on("click", function() { nextPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
+
+var taskState = newTaskState();
+
var makeFilter = function() {
var pass = [];
- $(".toggle-filter").each(function(i, e) {
+ $(".toggle-filter, .radio-filter").each(function(i, e) {
if (e.checked) {
pass.push(e.id.substr(5));
}
});
+
return (function(item) {
+ var v = false;
+ if (item.values().taskid !== "") {
+ for (a in pass) {
+ if (pass[a] == "all-tasks") { v = true; }
+ else if (pass[a] == "successful-tasks" && taskState[item.values().taskid].outcome == "success") { v = true; }
+ else if (pass[a] == "failed-tasks" && taskState[item.values().taskid].outcome == "failure") { v = true; }
+ }
+ } else {
+ v = true;
+ }
for (a in pass) {
- if (pass[a] == item.values().type) { return true; }
+ if (pass[a] == item.values().type) { return v; }
}
return false;
});
}
-<% logcollection = Collection.find @object.log %>
-
-$.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
- done(function(data, status, jqxhr) {
- logViewer.filter();
- addToLogViewer(logViewer, data.split("\n"));
- logViewer.filter(makeFilter());
- $("#logloadspinner").detach();
- });
-
-$(".toggle-filter").on("change", function() {
+<% if @object.log %>
+ <% logcollection = Collection.find @object.log %>
+ <% if logcollection %>
+ log_size = <%= logcollection.files[0][2] %>
+ log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
+ logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
+ $("#log-viewer-download-url").attr('href', logcollection_url);
+ $("#log-viewer-download-pane").show();
+ if (log_size > log_maxbytes) {
+ range_header = { 'Range': 'bytes=0-' + log_maxbytes };
+ } else {
+ range_header = null;
+ }
+ $.ajax(logcollection_url, { headers: range_header }).
+ done(function(data, status, jqxhr) {
+ logViewer.filter();
+ addToLogViewer(logViewer, data.split("\n"), taskState);
+ logViewer.filter(makeFilter());
+ content_range_hdr = jqxhr.getResponseHeader('Content-Range');
+ var v = content_range_hdr && content_range_hdr.match(/bytes \d+-(\d+)\/(.+)/);
+ short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]);
+ if (jqxhr.status == 206 && short_log) {
+ $("#log-viewer-overview").html(
+ '<p>Showing only ' + data.length + ' bytes of this log.' +
+ ' Timing information is unavailable since' +
+ ' the full log was not retrieved.</p>'
+ );
+ } else {
+ generateJobOverview("#log-viewer-overview", logViewer, taskState);
+ }
+ $("#log-viewer .spinner").detach();
+ }).
+ fail(function(jqxhr, status, error) {
+ $("#log-viewer .spinner").detach();
+ });
+ <% end %>
+<% else %>
+ <%# Live log loading not implemented yet. %>
+<% end %>
+
+$(".toggle-filter, .radio-filter").on("change", function() {
logViewer.filter(makeFilter());
});
});
$("#sort-by-time").on("change", function() {
- logViewer.sort("id");
+ logViewer.sort("id", {sortFunction: sortById});
});
$("#sort-by-task").on("change", function() {
- logViewer.sort("taskid");
+ logViewer.sort("taskid", {sortFunction: sortByTask});
+});
+
+$("#sort-by-node").on("change", function() {
+ logViewer.sort("node", {sortFunction: sortByNode});
+});
+
+$("#set-show-failed-only").on("click", function() {
+ $("#sort-by-task").prop("checked", true);
+ $("#show-failed-tasks").prop("checked", true);
+ $("#show-crunch").prop("checked", false);
+ $("#show-task-dispatch").prop("checked", true);
+ $("#show-script-print").prop("checked", true);
+ $("#show-crunchstat").prop("checked", false);
+ logViewer.filter(makeFilter());
+ logViewer.sort("taskid", {sortFunction: sortByTask});
});
})();
<div id="log-viewer">
- <div class="radio-inline">
+ <h3>Summary</h3>
+ <p id="log-viewer-overview">
+ <% if !logcollection %>
+ The collection containing the job log was not found.
+ <% end %>
+ </p>
+
+ <p id="log-viewer-download-pane" style="display:none">
+ <a id="log-viewer-download-url" href="">Download the full log</a>
+ </p>
+
+ <div class="h3">Log
+
+ <span class="pull-right">
+ <% if @object.andand.tasks_summary.andand[:failed] and @object.tasks_summary[:failed] > 0 %>
+ <button id="set-show-failed-only" class="btn btn-danger">
+ Show failed task diagnostics only
+ </button>
+ <% end %>
+
+ <button id="filter-all" class="btn">
+ Select all
+ </button>
+ <button id="filter-none" class="btn">
+ Select none
+ </button>
+ </span>
+ </div>
+
+ <input class="search pull-right" style="margin-top: 1em" placeholder="Search" />
+
+ <div>
+ <div class="radio-inline log-viewer-button" style="margin-left: 10px">
<label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
</div>
- <div class="radio-inline">
+ <div class="radio-inline log-viewer-button">
+ <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
+ </div>
+
+ <div class="radio-inline log-viewer-button">
<label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
</div>
-<br>
- <div class="checkbox-inline">
- <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
</div>
- <div class="checkbox-inline">
- <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
- </div>
- <div class="checkbox-inline">
- <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
+
+ <div>
+ <div class="radio-inline log-viewer-button" style="margin-left: 10px">
+ <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="radio-filter"> Show all tasks</label>
+ </div>
+ <div class="radio-inline log-viewer-button">
+ <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only successful tasks</label>
+ </div>
+ <div class="radio-inline log-viewer-button">
+ <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only failed tasks</label>
+ </div>
</div>
- <div class="checkbox-inline">
- <label><input id="show-job-progress" type="checkbox" checked="true" class="toggle-filter"> Show job progress</label>
+
+ <div>
+ <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
+ <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch diagnostics</label>
+ </div>
+ <div class="checkbox-inline log-viewer-button">
+ <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
+ </div>
+ <div class="checkbox-inline log-viewer-button">
+ <label><input id="show-task-print" type="checkbox" checked="true" class="toggle-filter"> Show task diagnostics</label>
+ </div>
+ <div class="checkbox-inline log-viewer-button">
+ <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
+ </div>
+
</div>
-<div class="pull-right">
- <button id="filter-all" class="btn">
- Select all
- </button>
- <button id="filter-none" class="btn">
- Select none
- </button>
-</div>
+ <div class="smart-scroll" data-smart-scroll-padding-bottom="50" style="margin-bottom: 0px">
+ <table class="log-viewer-table">
+ <thead>
+ <tr>
+ <th class="id" data-sort="id"></th>
+ <th class="timestamp" data-sort="timestamp">Timestamp</th>
+ <th class="node" data-sort="node">Node</th>
+ <th class="slot" data-sort="slot">Slot</th>
+ <th class="type" data-sort="type">Log type</th>
+ <th class="taskid" data-sort="taskid">Task</th>
+ <th class="message" data-sort="message">Message</th>
+ </tr>
+ </thead>
+ <tbody class="list">
+ <tr>
+ <td class="id"></td>
+ <td class="timestamp"></td>
+ <td class="node"></td>
+ <td class="slot"></td>
+ <td class="type"></td>
+ <td class="taskid"></td>
+ <td class="message"></td>
+ </tr>
+ </tbody>
+ </table>
+
+ <% if @object.log and logcollection %>
+ <div class="spinner spinner-32px"></div>
+ <% end %>
- <table style='width: 100%; font-family:"Lucida Console", Monaco, monospace; font-size: 11px'>
- <thead>
- <tr>
- <th class="sort" data-sort="id" style="display:none;"></th>
- <th class="sort" data-sort="timestamp" style="width: 12em">Timestamp</th>
- <th class="sort" data-sort="type" style="width: 8em">Log type</th>
- <th class="sort" data-sort="taskid" style="width: 4em">Task</th>
- <th class="sort" data-sort="message" >Message</th>
- </tr>
- </thead>
- <tbody class="list">
- <tr>
- <td class="id" style="display:none;">0</td>
- <td class="timestamp"></td>
- <td class="type"></td>
- <td class="taskid" style="text-align: center"></td>
- <td class="message"></td>
- </tr>
- </tbody>
- </table>
+ </div>
+
+ <div class="log-viewer-paging-div" style="margin-bottom: -15px">
+ <a href="#" class="log-viewer-page-up"><span class='glyphicon glyphicon-arrow-up'></span></a>
+ <span class="log-viewer-paging"></span>
+ <a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>
+ </div>
</div>
-<%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>
+<% end %>