Sha256: d0ee6e7584f8df08cad823fb47f85fd3b837e6eaf64faf33983a1547c1ed92bc

Contents?: true

Size: 499 Bytes

Versions: 6

Compression:

Stored size: 499 Bytes

Contents

require 'thread'

require_relative 'base'


module Anschel
  class Output
    class Device < Base
      def initialize config, stats, log
        path   = config.delete(:path) || '/dev/stdout'
        qsize  = config.delete(:queue_size) || 2000
        @queue = SizedQueue.new qsize

        @thread = Thread.new do
          File.open(path, 'w') do |f|
            loop do
              f.puts @queue.shift
              f.flush
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
anschel-0.7.16 lib/anschel/output/device.rb
anschel-0.7.15 lib/anschel/output/device.rb
anschel-0.7.14 lib/anschel/output/device.rb
anschel-0.7.13 lib/anschel/output/device.rb
anschel-0.7.12 lib/anschel/output/device.rb
anschel-0.7.11 lib/anschel/output/device.rb