Module: Rails::Pretty::Logger::DashboardsHelper
- Defined in:
- app/helpers/rails/pretty/logger/dashboards_helper.rb
Instance Method Summary collapse
- #check_highlight(line) ⇒ Object
- #check_rails_version ⇒ Object
- #is_file_active(name, params) ⇒ Object
- #is_page_active(index, params) ⇒ Object
- #is_stdout? ⇒ Boolean
- #parse_parameters(line) ⇒ Object
- #set_divider(params) ⇒ Object
- #time_now ⇒ Object
Instance Method Details
#check_highlight(line) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'app/helpers/rails/pretty/logger/dashboards_helper.rb', line 3 def check_highlight(line) return "<div class='highlight'>#{line.remove('[HIGHLIGHT]')}</div>".html_safe if line.include?("[HIGHLIGHT]") if line.include?("Parameters:") parse_parameters(line) else line end end |
#check_rails_version ⇒ Object
38 39 40 |
# File 'app/helpers/rails/pretty/logger/dashboards_helper.rb', line 38 def check_rails_version Rails::VERSION::STRING[0..2].to_f < 5.2 end |
#is_file_active(name, params) ⇒ Object
30 31 32 |
# File 'app/helpers/rails/pretty/logger/dashboards_helper.rb', line 30 def is_file_active(name, params) "active" if params[:log_file] == name end |
#is_page_active(index, params) ⇒ Object
34 35 36 |
# File 'app/helpers/rails/pretty/logger/dashboards_helper.rb', line 34 def is_page_active(index, params) "active" if params[:page].to_i == index end |
#is_stdout? ⇒ Boolean
16 17 18 |
# File 'app/helpers/rails/pretty/logger/dashboards_helper.rb', line 16 def is_stdout? ENV["RAILS_LOG_TO_STDOUT"].present? end |
#parse_parameters(line) ⇒ Object
42 43 44 45 46 47 |
# File 'app/helpers/rails/pretty/logger/dashboards_helper.rb', line 42 def parse_parameters(line) parameters = line[line.index("Parameters:") + 12 ..line.length] hash = JSON.parse parameters.gsub('=>', ':') rescue nil h = hash.reduce("<strong> Parameters: </strong> <br/> ") {|memo, (k,v)| memo += "<strong> #{k}: </strong> #{v}, "} rescue nil h.html_safe rescue nil end |
#set_divider(params) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/rails/pretty/logger/dashboards_helper.rb', line 20 def set_divider(params) if params[:date_range].blank? 100 elsif params[:date_range][:divider].blank? 100 else params[:date_range][:divider] end end |
#time_now ⇒ Object
12 13 14 |
# File 'app/helpers/rails/pretty/logger/dashboards_helper.rb', line 12 def time_now Time.now.strftime("%Y-%m-%d") end |