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)) {
20 if (/^stderr crunchstat: /.test(message)) {
22 message = message.substr(19);
23 } else if (/^stderr srun: /.test(message)) {
24 type = "task-dispatch";
25 message = message.substr(7);
26 } else if (/^stderr slurmd/.test(message)) {
27 type = "task-dispatch";
28 message = message.substr(7);
31 message = message.substr(7);
34 type = "task-dispatch";
37 if (/^status: /.test(message)) {
39 message = message.substr(8);
46 id: logViewer.items.length,
47 timestamp: ts.toLocaleDateString() + " " + ts.toLocaleTimeString(),
54 console.log("Did not parse: " + lines[a]);
61 var logViewer = new List('log-viewer', {
62 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
66 var makeFilter = function() {
68 $(".toggle-filter").each(function(i, e) {
70 pass.push(e.id.substr(5));
73 return (function(item) {
75 if (pass[a] == item.values().type) { return true; }
82 <% logcollection = Collection.find @object.log %>
84 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
85 done(function(data, status, jqxhr) {
87 addToLogViewer(logViewer, data.split("\n"));
88 logViewer.filter(makeFilter());
89 $("#logloadspinner").detach();
92 <%# Live log loading not implemented yet. %>
95 $(".toggle-filter").on("change", function() {
96 logViewer.filter(makeFilter());
99 $("#filter-all").on("click", function() {
100 $(".toggle-filter").each(function(i, f) { f.checked = true; });
101 logViewer.filter(makeFilter());
104 $("#filter-none").on("click", function() {
105 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
106 logViewer.filter(makeFilter());
109 $("#sort-by-time").on("change", function() {
110 logViewer.sort("id");
113 $("#sort-by-task").on("change", function() {
114 logViewer.sort("taskid");
121 <div id="log-viewer">
123 <div class="radio-inline">
124 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
126 <div class="radio-inline">
127 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
130 <div class="checkbox-inline">
131 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
133 <div class="checkbox-inline">
134 <label><input id="show-job-status" type="checkbox" checked="true" class="toggle-filter"> Show job status</label>
136 <div class="checkbox-inline">
137 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
139 <div class="checkbox-inline">
140 <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
142 <div class="checkbox-inline">
143 <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
146 <div class="pull-right">
147 <button id="filter-all" class="btn">
150 <button id="filter-none" class="btn">
155 <table class="log-viewer-table">
158 <th class="id" data-sort="id"></th>
159 <th class="timestamp" data-sort="timestamp">Timestamp</th>
160 <th class="type" data-sort="type">Log type</th>
161 <th class="taskid" data-sort="taskid">Task</th>
162 <th class="message" data-sort="message">Message</th>
168 <td class="timestamp"></td>
169 <td class="type"></td>
170 <td class="taskid"></td>
171 <td class="message"></td>
178 <% if !@object.log %>
179 This job is still running. The job log will be available when the job is complete.
182 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>