Sha256: 5abd5fca717c6f387dba61c04a8f954d48cb528c5f9e276602c29fe583ee8b5b

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

#
# Fluent
#
# Copyright (C) 2011 FURUHASHI Sadayuki
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#
module Fluent
module Logger


class TestLogger < LoggerBase
  def initialize(queue=[])
    @queue = queue
    @max = 1024
    @close_called = 0
  end

  attr_accessor :max
  attr_reader :queue
  attr_reader :close_called

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

  def close
    @close_called += 1
  end

  def closed?
    @close_called > 0
  end
end


end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-logger-0.3.1 lib/fluent/logger/test.rb
fluent-logger-0.3.0 lib/fluent/logger/test.rb