lib/tailog.rb in tailog-0.2.2 vs lib/tailog.rb in tailog-0.2.3

- old
+ new

@@ -38,12 +38,16 @@ post '/logs' do begin file_path = File.join Tailog.log_path, params[:file] file = File.open file_path file_size = file.size - seek = params[:seek] && params[:seek][Tailog.server_uuid] || file_size - file.seek seek.to_i - content = erb :'logs/list', locals: { file: file }, layout: false + tail = if seek = params[:seek] && params[:seek][Tailog.server_uuid] + file.seek seek.to_i + file + else + file.tail(100).join("\n") + end + content = erb :'logs/list', locals: { file: tail }, layout: false file.close rescue => error content = erb :error, locals: { error: error }, layout: false end