Class: Rack::Bug::LogPanel
- Inherits:
-
Panel
- Object
- Panel
- Rack::Bug::LogPanel
show all
- Defined in:
- lib/rack/bug/panels/log_panel.rb
Defined Under Namespace
Classes: LogEntry
Instance Attribute Summary
Attributes inherited from Panel
#request
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Panel
#after, #before, #call, #has_content?, #panel_app, #render
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.
39
40
41
42
43
44
45
46
|
# File 'lib/rack/bug/panels/log_panel.rb', line 39
def initialize(app)
if Rails.logger and not Rails.logger.class.include?(Rack::Bug::LoggerExtension)
Rails.logger.class.class_eval do
include Rack::Bug::LoggerExtension
end
end
super
end
|
Class Method Details
.logs ⇒ Object
35
36
37
|
# File 'lib/rack/bug/panels/log_panel.rb', line 35
def self.logs
Thread.current["rack.bug.logs"] ||= []
end
|
.record(message, log_level) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/rack/bug/panels/log_panel.rb', line 22
def self.record(message, log_level)
return unless Rack::Bug.enabled?
return unless message
Thread.current["rack.bug.logs.start"] ||= Time.now
timestamp = ((Time.now - Thread.current["rack.bug.logs.start"]) * 1000).to_i
logs << LogEntry.new(log_level, timestamp, message)
end
|
.reset ⇒ Object
30
31
32
33
|
# File 'lib/rack/bug/panels/log_panel.rb', line 30
def self.reset
Thread.current["rack.bug.logs"] = []
Thread.current["rack.bug.logs.start"] = nil
end
|
Instance Method Details
#content ⇒ Object
56
57
58
59
60
|
# File 'lib/rack/bug/panels/log_panel.rb', line 56
def content
result = render_template "panels/log", :logs => self.class.logs
self.class.reset
return result
end
|
#heading ⇒ Object
52
53
54
|
# File 'lib/rack/bug/panels/log_panel.rb', line 52
def heading
"Log"
end
|
#name ⇒ Object
48
49
50
|
# File 'lib/rack/bug/panels/log_panel.rb', line 48
def name
"log"
end
|