Class: Logs::LogsController

Inherits:
ApplicationController show all
Includes:
ApplicationHelper, Concerns::LogsLoader, Concerns::Pagination
Defined in:
app/controllers/logs/logs_controller.rb

Constant Summary

Constants included from Concerns::Pagination

Concerns::Pagination::PAGE, Concerns::Pagination::PER_PAGE

Instance Method Summary collapse

Methods included from ApplicationHelper

#download_log_path, #lines, #log_file, #log_file_path, #tail_log_path

Instance Method Details

#downloadObject



16
17
18
19
# File 'app/controllers/logs/logs_controller.rb', line 16

def download
  file_name = params[:f]
  send_file Logs::Viewer.log_path(file_name)
end

#indexObject



12
# File 'app/controllers/logs/logs_controller.rb', line 12

def index; end

#showObject



14
# File 'app/controllers/logs/logs_controller.rb', line 14

def show; end

#tailObject



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/logs/logs_controller.rb', line 21

def tail
  @file_name = params[:f]
  log = File.join(Logs::Viewer.log_path(@file_name))
  @lines = `tail -500 #{ log }`.split(/\n/)
  @lines.reverse!
  respond_to do |wants|
    wants.html
    wants.json{ render(:json => @lines) }
  end
end