Sha256: 81c8c20c0ffac2a8a8ecd64ec2ddd1fca3433b9beb91cfc397e76c3b89173708
Contents?: true
Size: 1.07 KB
Versions: 7
Compression:
Stored size: 1.07 KB
Contents
require 'logger' require 'logstash-logger/tagged_logging' module LogStashLogger def self.new(*args) opts = extract_opts(*args) device = Device.new(opts) ::Logger.new(device).tap do |logger| logger.instance_variable_set(:@device, device) logger.extend(self) logger.extend(TaggedLogging) logger.formatter = Formatter.new end end def self.extended(base) base.instance_eval do class << self attr_reader :device end def flush !!@device.flush end end end protected def self.extract_opts(*args) args.flatten! if args.length > 1 if args.all?{|arg| arg.is_a?(Hash)} # Array of Hashes args else # Deprecated host/port/type syntax puts "[LogStashLogger] (host, port, type) constructor is deprecated. Please use an options hash instead." host, port, type = *args {host: host, port: port, type: type} end elsif Hash === args[0] args[0] else fail ArgumentError, "Invalid LogStashLogger options" end end end
Version data entries
7 entries across 7 versions & 1 rubygems