require "#{File.dirname(__FILE__)}/abstract_note" module Footnotes module Notes class LogNote < AbstractNote def self.logs @@logs ||= [] end def self.log(message) logs << message unless message =~ /SQL|SELECT/ end def self.clear_logs @@logs = [] end def initialize(controller) @controller = controller end def start! self.class.clear_logs end def title "Log (#{self.class.logs.size})" end def content self.class.logs.map do |l| escape(l.gsub(/\e\[.+?m/, '')) end.join('
') end end end module LoggingExtensions def add(*args, &block) message = super Footnotes::Notes::LogNote.log(message) message end end end