Sha256: a17d390f13ee0270b68cc74771ef01415e9228f41594f19453239864a4e88c80

Contents?: true

Size: 692 Bytes

Versions: 1

Compression:

Stored size: 692 Bytes

Contents

require 'logstash-logger/device/base'

module LogStashLogger
  module Device
    DEFAULT_TYPE = :udp

    autoload :Base, 'logstash-logger/device/base'
    autoload :Socket, 'logstash-logger/device/socket'
    autoload :UDP, 'logstash-logger/device/udp'
    autoload :TCP, 'logstash-logger/device/tcp'
    autoload :Stdout, 'logstash-logger/device/stdout'

    def self.new(opts)
      type = opts.delete(:type) || DEFAULT_TYPE

      device_klass_for(type).new(opts)
    end

    def self.device_klass_for(type)
      case type
        when :udp then UDP
        when :tcp then TCP
        when :stdout then Stdout
        else fail ArgumentError, 'Invalid type'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-logger-0.5.0 lib/logstash-logger/device.rb