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 if (typeof v[11] === 'undefined') {
15 if (v11 != ' ') {
16 if (/^stderr /.test(message)) {
19 type = "task-dispatch";
22 if (/^status: /.test(message)) {
23 type = "job-progress";
30 id: logViewer.items.length,
31 timestamp: v[1] + " " + v[5],
38 console.log("Did not parse: " + lines[a]);
45 var logViewer = new List('log-viewer', {
46 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type']
49 var makeFilter = function() {
51 $(".toggle-filter").each(function(i, e) {
53 pass.push(e.id.substr(5));
56 return (function(item) {
58 if (pass[a] == item.values().type) { return true; }
64 <% logcollection = Collection.find @object.log %>
66 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
67 done(function(data, status, jqxhr) {
69 addToLogViewer(logViewer, data.split("\n"));
70 logViewer.filter(makeFilter());
71 $("#logloadspinner").detach();
74 $(".toggle-filter").on("change", function() {
75 logViewer.filter(makeFilter());
78 $("#filter-all").on("click", function() {
79 $(".toggle-filter").each(function(i, f) { f.checked = true; });
80 logViewer.filter(makeFilter());
83 $("#filter-none").on("click", function() {
84 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
85 logViewer.filter(makeFilter());
88 $("#sort-by-time").on("change", function() {
92 $("#sort-by-task").on("change", function() {
93 logViewer.sort("taskid");
100 <div id="log-viewer">
102 <div class="radio-inline">
103 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
105 <div class="radio-inline">
106 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
109 <div class="checkbox-inline">
110 <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
112 <div class="checkbox-inline">
113 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
115 <div class="checkbox-inline">
116 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
118 <div class="checkbox-inline">
119 <label><input id="show-job-progress" type="checkbox" checked="true" class="toggle-filter"> Show job progress</label>
122 <div class="pull-right">
123 <button id="filter-all" class="btn">
126 <button id="filter-none" class="btn">
131 <table style='width: 100%; font-family:"Lucida Console", Monaco, monospace; font-size: 11px'>
134 <th class="sort" data-sort="id" style="display:none;"></th>
135 <th class="sort" data-sort="timestamp" style="width: 12em">Timestamp</th>
136 <th class="sort" data-sort="type" style="width: 8em">Log type</th>
137 <th class="sort" data-sort="taskid" style="width: 4em">Task</th>
138 <th class="sort" data-sort="message" >Message</th>
143 <td class="id" style="display:none;">0</td>
144 <td class="timestamp"></td>
145 <td class="type"></td>
146 <td class="taskid" style="text-align: center"></td>
147 <td class="message"></td>
154 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>