Sha256: da69b07675d5fa3959bcdcb6a8910a110ff6c98bd0f150801836796ac5fa55cb
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require 'tailog/version' require 'sinatra/base' require 'active_support/configurable' require 'tailog/ext/file' require 'securerandom' require 'json' module Tailog include ActiveSupport::Configurable config_accessor :log_path do File.expand_path("log", Dir.pwd) end config_accessor :server_uuid do SecureRandom.uuid end class App < Sinatra::Base set :root, File.expand_path("../../app", __FILE__) set :public_folder do "#{root}/assets" end set :views do "#{root}/views" end helpers do def h(text) Rack::Utils.escape_html(text) end end get '/' do redirect to('/logs') end get '/logs' do erb :'logs/index' end post '/logs' do begin file_path = File.join Tailog.log_path, params[:file] file = File.open file_path file_size = file.size 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 { server_uuid: Tailog.server_uuid, file_size: file_size, content: content }.to_json end get '/env' do erb :env end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tailog-0.2.3 | lib/tailog.rb |