Class: Rack::Insight::LogPanel

Inherits:
Panel
  • Object
show all
Defined in:
lib/rack/insight/panels/log_panel.rb

Defined Under Namespace

Classes: LogEntry

Instance Attribute Summary

Attributes inherited from Panel

#request

Instance Method Summary collapse

Methods inherited from Panel

#after, #before, #bool_prop, #call, #camelized_name, #content, current_panel_file, excluded, file_index, from_file, #handle_error_for, #has_content?, #has_custom_probes?, has_table, #has_table?, #heading, #heading_for_request, inherited, #inspect, #is_magic?, #is_probing?, #name, #panel_app, panel_exclusion, panel_mappings, #render, set_sub_class_template_root, #underscored_name

Methods included from Database::EigenClient

included

Methods included from Instrumentation::EigenClient

included

Methods included from Logging

logger, verbose, verbosity

Methods included from Instrumentation::Client

#before_detect, #probe, #request_finish, #request_start

Methods included from Database::RequestDataClient

#count, #key_sql_template, #retrieve, #store, #table_length, #table_setup

Methods included from Render

#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params

Constructor Details

#initialize(app) ⇒ LogPanel

Returns a new instance of LogPanel.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rack/insight/panels/log_panel.rb', line 25

def initialize(app)

  # Call super before setting up probes in case there are any custom probes configured
  super # will setup custom probes

  unless is_probing?
    probe(self) do
      # Trying to be smart...
      if defined?(ActiveSupport)
        instrument "ActiveSupport::BufferedLogger" do
          instance_probe :add
        end
      else
        instrument "Logger" do
          instance_probe :add
        end
      end
    end
  end
end

Instance Method Details

#after_detect(method_call, timing, args, message) ⇒ Object



19
20
21
22
23
# File 'lib/rack/insight/panels/log_panel.rb', line 19

def after_detect(method_call, timing, args, message)
  message = args[1] || args[2] unless message.is_a?(String)
  log_level = args[0]
  store(@env, LogEntry.new(log_level, timing.delta_t, message))
end

#content_for_request(number) ⇒ Object



46
47
48
# File 'lib/rack/insight/panels/log_panel.rb', line 46

def content_for_request(number)
  render_template "panels/log", :logs => retrieve(number)
end