lib/semantic_logger/appender.rb in semantic_logger-4.8.2 vs lib/semantic_logger/appender.rb in semantic_logger-4.9.0

- old
+ new

@@ -7,10 +7,11 @@ autoload :Elasticsearch, "semantic_logger/appender/elasticsearch" autoload :ElasticsearchHttp, "semantic_logger/appender/elasticsearch_http" autoload :File, "semantic_logger/appender/file" autoload :Graylog, "semantic_logger/appender/graylog" autoload :Honeybadger, "semantic_logger/appender/honeybadger" + autoload :IO, "semantic_logger/appender/io" autoload :Kafka, "semantic_logger/appender/kafka" autoload :Sentry, "semantic_logger/appender/sentry" autoload :Http, "semantic_logger/appender/http" autoload :MongoDB, "semantic_logger/appender/mongodb" autoload :NewRelic, "semantic_logger/appender/new_relic" @@ -30,11 +31,11 @@ **args, &block) appender = build(**args, &block) # If appender implements #batch, then it should use the batch proxy by default. - batch = true if batch.nil? && appender.respond_to?(:batch) + batch = true if batch.nil? && appender.respond_to?(:batch) if batch == true Appender::AsyncBatch.new( appender: appender, max_queue_size: max_queue_size, @@ -54,11 +55,13 @@ end end # Returns [Subscriber] instance from the supplied options. def self.build(io: nil, file_name: nil, appender: nil, metric: nil, logger: nil, **args, &block) - if io || file_name - SemanticLogger::Appender::File.new(io: io, file_name: file_name, **args, &block) + if file_name + SemanticLogger::Appender::File.new(file_name, **args, &block) + elsif io + SemanticLogger::Appender::IO.new(io, **args, &block) elsif logger SemanticLogger::Appender::Wrapper.new(logger: logger, **args, &block) elsif appender if appender.is_a?(Symbol) SemanticLogger::Utils.constantize_symbol(appender).new(**args)