Class: Footnotes::Notes::LogNote
- Inherits:
-
AbstractNote
show all
- Defined in:
- lib/rails-footnotes/notes/log_note.rb,
lib/rails-footnotes/notes/log_note/note_logger.rb
Defined Under Namespace
Classes: NoteLogger
Class Method Summary
collapse
Instance Method Summary
collapse
close!, #escape, #has_fieldset?, #hash_to_xml_attributes, included?, #initialize, #javascript, #legend, #link, #mount_table, #mount_table_for_hash, #onclick, #prefix?, #row, #stylesheet, title, #to_sym, to_sym, #valid?
Class Method Details
.start!(controller) ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/rails-footnotes/notes/log_note.rb', line 10
def self.start!(controller)
self.logs = []
self.original_logger = Rails.logger
note_logger = NoteLogger.new(self.logs)
note_logger.level = self.original_logger.level
note_logger.formatter = self.original_logger.kind_of?(Logger) ? self.original_logger.formatter : ActiveSupport::Logger::SimpleFormatter.new
extend_module = defined?(ActiveSupport::Logger) ? ActiveSupport::Logger.broadcast(note_logger) : NoteLogger.broadcast(note_logger)
Rails.logger = self.original_logger.dup.extend(extend_module)
end
|
Instance Method Details
#content ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/rails-footnotes/notes/log_note.rb', line 25
def content
result = '<table>'
log.compact.each do |l|
result << "<tr><td>#{l.gsub(/\e\[.+?m/, '')}</td></tr>"
end
result << '</table>'
Rails.logger = self.class.original_logger
result
end
|
#log ⇒ Object
36
37
38
|
# File 'lib/rails-footnotes/notes/log_note.rb', line 36
def log
self.class.logs
end
|
#title ⇒ Object
21
22
23
|
# File 'lib/rails-footnotes/notes/log_note.rb', line 21
def title
"Log (#{log.count})"
end
|