lib/logstash-logger/device.rb in logstash-logger-0.7.0 vs lib/logstash-logger/device.rb in logstash-logger-0.8.0
- old
+ new
@@ -12,14 +12,29 @@
autoload :Unix, 'logstash-logger/device/unix'
autoload :Redis, 'logstash-logger/device/redis'
autoload :File, 'logstash-logger/device/file'
autoload :IO, 'logstash-logger/device/io'
autoload :Stdout, 'logstash-logger/device/stdout'
+ autoload :Stderr, 'logstash-logger/device/stderr'
+ autoload :MultiDelegator, 'logstash-logger/device/multi_delegator'
def self.new(opts)
opts = opts.dup
+ if opts.is_a?(Array)
+ # Multiple device configs supplied... create a MultiDelegator
+ devices = opts.map{|opt| build_device(opt)}
+ Device::MultiDelegator.new(*devices)
+ elsif Hash
+ # Create a single device
+ build_device(opts)
+ else
+ raise ArgumentError, "Invalid device options: must be a Hash or an Array of Hashes"
+ end
+ end
+
+ def self.build_device(opts)
if parsed_uri_opts = parse_uri_config(opts)
opts = parsed_uri_opts
end
type = opts.delete(:type) || DEFAULT_TYPE
@@ -41,9 +56,10 @@
when :unix then Unix
when :file then File
when :redis then Redis
when :io then IO
when :stdout then Stdout
+ when :stderr then Stderr
else fail ArgumentError, 'Invalid type'
end
end
end
end