Sha256: 25c6a01d2e7c421ed6518239ee1ab2b9cfef5280bbe92847877819af6252bfac

Contents?: true

Size: 912 Bytes

Versions: 11

Compression:

Stored size: 912 Bytes

Contents

module Footnotes
  module Notes
    class LogNote < AbstractNote
      @@log = []

      def self.log(message)
        @@log << message
      end

      def initialize(controller)
        @controller = controller
      end

      def title
        "Log (#{log.count("\n")})"
      end

      def content
        escape(log.gsub(/\e\[.+?m/, '')).gsub("\n", '<br />')
      end

      def log
        unless @log
          @log = @@log.join('')
          @@log = []
          if rindex = @log.rindex('Processing '+@controller.class.name+'#'+@controller.action_name)
            @log = @log[rindex..-1]
          end
        end
        @log
      end

      module LoggingExtensions
        def add(*args, &block)
          logged_message = super
          Footnotes::Notes::LogNote.log(logged_message)
          logged_message
        end
      end

      Rails.logger.extend LoggingExtensions
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rails-footnotes-3.7.9 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.8 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.7 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.6 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.5 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.5.rc4 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.5.rc3 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.5.rc2 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.5.rc1 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.4 lib/rails-footnotes/notes/log_note.rb
rails-footnotes-3.7.3 lib/rails-footnotes/notes/log_note.rb