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 # clear the logs for the next request old_logs, @@logs = @@logs, [] return old_logs end def initialize(controller) @controller = controller end def title "Log (#{@num})" end def content @num = self.class.logs.size self.class.clear_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