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; }
67 <% logcollection = Collection.find @object.log %>
69 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
70 done(function(data, status, jqxhr) {
72 addToLogViewer(logViewer, data.split("\n"));
73 logViewer.filter(makeFilter());
74 $("#logloadspinner").detach();
78 Log.filter([['object_uuid', '=', @object.uuid],
79 ['event_type', '=', 'stderr']]).order(["id", "asc"]).each do |l|
80 backlog += l.properties["text"]
83 var backlog = "<%=j backlog %>";
85 addToLogViewer(logViewer, backlog.split("\n"));
86 logViewer.filter(makeFilter());
90 $(".toggle-filter").on("change", function() {
91 logViewer.filter(makeFilter());
94 $("#filter-all").on("click", function() {
95 $(".toggle-filter").each(function(i, f) { f.checked = true; });
96 logViewer.filter(makeFilter());
99 $("#filter-none").on("click", function() {
100 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
101 logViewer.filter(makeFilter());
104 $("#sort-by-time").on("change", function() {
105 logViewer.sort("id");
108 $("#sort-by-task").on("change", function() {
109 logViewer.sort("taskid");
116 <div id="log-viewer">
118 <div class="radio-inline">
119 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
121 <div class="radio-inline">
122 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
125 <div class="checkbox-inline">
126 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
128 <div class="checkbox-inline">
129 <label><input id="show-job-status" type="checkbox" checked="true" class="toggle-filter"> Show job status</label>
131 <div class="checkbox-inline">
132 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
134 <div class="checkbox-inline">
135 <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
138 <div class="pull-right">
139 <button id="filter-all" class="btn">
142 <button id="filter-none" class="btn">
147 <table class="log-viewer-table">
150 <th class="id" data-sort="id"></th>
151 <th class="timestamp" data-sort="timestamp">Timestamp</th>
152 <th class="type" data-sort="type">Log type</th>
153 <th class="taskid" data-sort="taskid">Task</th>
154 <th class="message" data-sort="message">Message</th>
160 <td class="timestamp"></td>
161 <td class="type"></td>
162 <td class="taskid"></td>
163 <td class="message"></td>
170 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>