Class QueuedLogger
In: lib/queued_logger.rb
Parent: Logger

Methods

dequeue   enqueue   new   process_queue   queued?  

Public Class methods

[Source]

# File lib/queued_logger.rb, line 4
  def initialize(*args)
    super(*args)
    @queue = []
    @emitted = false
  end

Public Instance methods

[Source]

# File lib/queued_logger.rb, line 27
  def dequeue(level=nil, message=nil)
    if queued?
      @queue.clear
    elsif level and message
      send("%s_without_queue"%level, message) if @emitted
    end
    @emitted = false
  end

[Source]

# File lib/queued_logger.rb, line 22
  def enqueue(level, message)
    @queue << [level, message]
    @emitted = false
  end

[Source]

# File lib/queued_logger.rb, line 10
  def process_queue
    if queued?
      while true
        entry = @queue.shift or break
        severity, message = entry
        raw_method = "#{severity}_without_queue"
        severity_i = self.class.send(:const_get, severity.to_s.upcase)
        send(raw_method, message)
      end
    end
  end

[Source]

# File lib/queued_logger.rb, line 36
  def queued?
    ! @queue.empty?
  end

[Validate]