Class: Rails::Pretty::Logger::HourlyLogsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails/pretty/logger/hourly_logs_controller.rb

Constant Summary collapse

PER_PAGE =
12

Instance Method Summary collapse

Instance Method Details

#clear_logsObject



27
28
29
30
# File 'app/controllers/rails/pretty/logger/hourly_logs_controller.rb', line 27

def clear_logs
  @log.clear_logs
  redirect_to hourly_logs_path({log_file: @log.log_file})
end

#indexObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/rails/pretty/logger/hourly_logs_controller.rb', line 14

def index
  logs = PrettyLogger.get_hourly_log_file_list.values.select { |file| file[:file_size] > 0 }
  @hourly_logs_present = logs.any?
  logs = filter_logs(logs)
  logs = sort_logs(logs)

  @page = [index_params[:page].to_i, 1].max
  @total_pages = (logs.count.to_f / PER_PAGE).ceil
  @total_pages = 1 if @total_pages.zero?
  @page = @total_pages if @page > @total_pages
  @log_file_list = logs.slice((@page - 1) * PER_PAGE, PER_PAGE) || []
end

#logsObject



10
11
12
# File 'app/controllers/rails/pretty/logger/hourly_logs_controller.rb', line 10

def logs
  @log_data = tail_mode? ? @log.tail_log_data : @log.log_data
end