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
20
21
22
23
24
|
# 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 =
if self.original_logger.kind_of?(Logger)
self.original_logger.formatter
else
defined?(ActiveSupport::Logger) ? ActiveSupport::Logger::SimpleFormatter.new : Logger::SimpleFormatter.new
end
extend_module = defined?(ActiveSupport::Logger) ? ActiveSupport::Logger.broadcast(note_logger) : NoteLogger.broadcast(note_logger)
Rails.logger = self.original_logger.clone.extend(extend_module)
end
|
Instance Method Details
#content ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rails-footnotes/notes/log_note.rb', line 30
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
41
42
43
|
# File 'lib/rails-footnotes/notes/log_note.rb', line 41
def log
self.class.logs
end
|
#title ⇒ Object
26
27
28
|
# File 'lib/rails-footnotes/notes/log_note.rb', line 26
def title
"Log (#{log.count})"
end
|