Sha256: 5ea927a2e5a015f32c15312efa6e0469c8946ead22b5c9dad40904c8bf75108d

Contents?: true

Size: 1.47 KB

Versions: 17

Compression:

Stored size: 1.47 KB

Contents

module Footnotes
  module Notes
    class LogNote
      class NoteLogger < Logger

        def initialize(logs)
          @logs = logs
        end

        def add(severity, message = nil, progname = nil, &block)
          severity ||= UNKNOWN
          if severity < level
            return true
          end
          formatter = @formatter || Logger::Formatter.new
          @logs << formatter.call(format_severity(severity), Time.now, message, progname)
        end

        ## Backport from rails 4 for handling logging broadcast, should be removed when rails 3 is deprecated :

        # Broadcasts logs to multiple loggers.
        def self.broadcast(logger) # :nodoc:
          Module.new do
            define_method(:add) do |*args, &block|
              logger.add(*args, &block)
              super(*args, &block)
            end

            define_method(:<<) do |x|
              logger << x
              super(x)
            end

            define_method(:close) do
              logger.close
              super()
            end

            define_method(:progname=) do |name|
              logger.progname = name
              super(name)
            end

            define_method(:formatter=) do |formatter|
              logger.formatter = formatter
              super(formatter)
            end

            define_method(:level=) do |level|
              logger.level = level
              super(level)
            end
          end
        end

      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
rails-footnotes-7.0.0 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-5.0.0 lib/rails-footnotes/notes/log_note/note_logger.rb
rails6-footnotes-5.0.2 lib/rails-footnotes/notes/log_note/note_logger.rb
rails6-footnotes-5.0.1 lib/rails-footnotes/notes/log_note/note_logger.rb
rails6-footnotes-5.0.0 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.1.8 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.1.7 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.1.6 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.1.5 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.1.4 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.1.3 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.1.2 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.1.1 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.1.0 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.0.2 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.0.1 lib/rails-footnotes/notes/log_note/note_logger.rb
rails-footnotes-4.0.0 lib/rails-footnotes/notes/log_note/note_logger.rb