Class: Fluent::Logger::TestLogger

Inherits:
LoggerBase show all
Defined in:
lib/fluent/logger/test_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from LoggerBase

open, #post

Constructor Details

#initialize(queue = []) ⇒ TestLogger

Returns a new instance of TestLogger.



21
22
23
24
# File 'lib/fluent/logger/test_logger.rb', line 21

def initialize(queue=[])
  @queue = queue
  @max = 1024
end

Instance Attribute Details

#maxObject

Returns the value of attribute max.



26
27
28
# File 'lib/fluent/logger/test_logger.rb', line 26

def max
  @max
end

#queueObject (readonly)

Returns the value of attribute queue.



27
28
29
# File 'lib/fluent/logger/test_logger.rb', line 27

def queue
  @queue
end

Instance Method Details

#closeObject



45
46
# File 'lib/fluent/logger/test_logger.rb', line 45

def close
end

#post_with_time(tag, map, time) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fluent/logger/test_logger.rb', line 29

def post_with_time(tag, map, time)
  while @queue.size > @max-1
    @queue.shift
  end
  (class<<map;self;end).module_eval do
    define_method(:tag) { tag }
    define_method(:time) { time }
  end
  @queue << map
  true
end

#tag_queue(tag) ⇒ Object



41
42
43
# File 'lib/fluent/logger/test_logger.rb', line 41

def tag_queue(tag)
  @queue.find_all {|map| map.tag == tag }
end