3 function addToLogViewer(logViewer, lines) {
4 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+)? (.*)/;
6 var v = lines[a].match(re);
9 var ts = new Date(Date.UTC(v[2], v[3], v[4], v[6], v[7], v[8]));
12 if (typeof v[11] === 'undefined') {
18 if (v11 != ' ') {
19 if (/^stderr /.test(message)) {
21 message = message.substr(7);
23 type = "task-dispatch";
26 if (/^status: /.test(message)) {
28 message = message.substr(8);
35 id: logViewer.items.length,
36 timestamp: ts.toLocaleDateString() + " " + ts.toLocaleTimeString(),
43 console.log("Did not parse: " + lines[a]);
50 var logViewer = new List('log-viewer', {
51 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type']
54 var makeFilter = function() {
56 $(".toggle-filter").each(function(i, e) {
58 pass.push(e.id.substr(5));
61 return (function(item) {
63 if (pass[a] == item.values().type) { return true; }
70 <% logcollection = Collection.find @object.log %>
72 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
73 done(function(data, status, jqxhr) {
75 addToLogViewer(logViewer, data.split("\n"));
76 logViewer.filter(makeFilter());
77 $("#logloadspinner").detach();
80 <%# Live log loading not implemented yet. %>
83 $(".toggle-filter").on("change", function() {
84 logViewer.filter(makeFilter());
87 $("#filter-all").on("click", function() {
88 $(".toggle-filter").each(function(i, f) { f.checked = true; });
89 logViewer.filter(makeFilter());
92 $("#filter-none").on("click", function() {
93 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
94 logViewer.filter(makeFilter());
97 $("#sort-by-time").on("change", function() {
101 $("#sort-by-task").on("change", function() {
102 logViewer.sort("taskid");
109 <div id="log-viewer">
111 <div class="radio-inline">
112 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
114 <div class="radio-inline">
115 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
118 <div class="checkbox-inline">
119 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
121 <div class="checkbox-inline">
122 <label><input id="show-job-status" type="checkbox" checked="true" class="toggle-filter"> Show job status</label>
124 <div class="checkbox-inline">
125 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
127 <div class="checkbox-inline">
128 <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
131 <div class="pull-right">
132 <button id="filter-all" class="btn">
135 <button id="filter-none" class="btn">
140 <table class="log-viewer-table">
143 <th class="id" data-sort="id"></th>
144 <th class="timestamp" data-sort="timestamp">Timestamp</th>
145 <th class="type" data-sort="type">Log type</th>
146 <th class="taskid" data-sort="taskid">Task</th>
147 <th class="message" data-sort="message">Message</th>
153 <td class="timestamp"></td>
154 <td class="type"></td>
155 <td class="taskid"></td>
156 <td class="message"></td>
163 <% !if @object.log %>
164 This job is still running. The job log will be available when the job is complete.
167 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>