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)) {
18 message = message.substr(7);
20 type = "task-dispatch";
23 if (/^status: /.test(message)) {
25 message = message.substr(8);
32 id: logViewer.items.length,
33 timestamp: v[1] + " " + v[5],
40 console.log("Did not parse: " + lines[a]);
47 var logViewer = new List('log-viewer', {
48 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type']
51 var makeFilter = function() {
53 $(".toggle-filter").each(function(i, e) {
55 pass.push(e.id.substr(5));
58 return (function(item) {
60 if (pass[a] == item.values().type) { return true; }
66 <% logcollection = Collection.find @object.log %>
68 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
69 done(function(data, status, jqxhr) {
71 addToLogViewer(logViewer, data.split("\n"));
72 logViewer.filter(makeFilter());
73 $("#logloadspinner").detach();
76 $(".toggle-filter").on("change", function() {
77 logViewer.filter(makeFilter());
80 $("#filter-all").on("click", function() {
81 $(".toggle-filter").each(function(i, f) { f.checked = true; });
82 logViewer.filter(makeFilter());
85 $("#filter-none").on("click", function() {
86 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
87 logViewer.filter(makeFilter());
90 $("#sort-by-time").on("change", function() {
94 $("#sort-by-task").on("change", function() {
95 logViewer.sort("taskid");
102 <div id="log-viewer">
104 <div class="radio-inline">
105 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
107 <div class="radio-inline">
108 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
111 <div class="checkbox-inline">
112 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
114 <div class="checkbox-inline">
115 <label><input id="show-job-status" type="checkbox" checked="true" class="toggle-filter"> Show job status</label>
117 <div class="checkbox-inline">
118 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
120 <div class="checkbox-inline">
121 <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
124 <div class="pull-right">
125 <button id="filter-all" class="btn">
128 <button id="filter-none" class="btn">
133 <table class="log-viewer-table">
136 <th class="sort" data-sort="id"></th>
137 <th class="sort" data-sort="timestamp">Timestamp</th>
138 <th class="sort" data-sort="type">Log type</th>
139 <th class="sort" data-sort="taskid">Task</th>
140 <th class="sort" data-sort="message">Message</th>
146 <td class="timestamp"></td>
147 <td class="type"></td>
148 <td class="taskid"></td>
149 <td class="message"></td>
156 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>