Sha256: 21d3956ffee8418a2e48d74fbd6cdedb0dafaa6df8973e495482c19870fceb9b
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
<% begin %> <% raise RuntimeError, "Tailog.log_path is not present!" unless Tailog.log_path %> <% if params[:file] %> <% file_path = File.join Tailog.log_path, params[:file] %> <h3 class="page-header"><%= file_path %></h3> <% File.open file_path do |file| %> <div id="content"> <%= erb :'logs/list', locals: { file: file.tail(100).join("\n") } %> </div> <% end %> <script type="text/javascript"> window.fileSize = {}; window.fileSizeDone = {}; var $window = $(window), $document = $(document), $content = $("#content"); function loadMore() { $.post(window.location.href, { seek: window.fileSize }, function(json) { try { var data = JSON.parse(json); var fileSizeKey = data.server_uuid + '-' + data.file_size; if (window.fileSizeDone[fileSizeKey]) return; window.fileSizeDone[fileSizeKey] = true; window.fileSize[data.server_uuid] = data.file_size; if (!data.content) return; var shouldScrollToBottom = $window.scrollTop() + $window.height() == $document.height(); $(data.content).appendTo($content); if (shouldScrollToBottom) { $window.scrollTop($document.height() - $window.height()); } } catch (error) { console.log(error) } }); } setInterval(loadMore, 3000); loadMore(); </script> <% else %> <% Dir[File.join Tailog.log_path, '**/*.log'].each do |file| %> <% relative_file = Pathname.new(file).relative_path_from(Pathname.new(Tailog.log_path)) %> <a href="?file=<%= relative_file %>"><%= file %></a> <% end %> <% end %> <% rescue => error %> <%= erb :error, locals: { error: error }, layout: false %> <% end %>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tailog-0.2.2 | app/views/logs/index.erb |