lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-0.5.2 vs lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-0.5.3

- old
+ new

@@ -42,17 +42,16 @@ if conf.has_key?('s3_endpoint') raise ConfigError, "s3_endpoint parameter is removed. Use s3_region instead" end begin - @compressor = COMPRESSOR_REGISTRY.lookup(@store_as).new + @compressor = COMPRESSOR_REGISTRY.lookup(@store_as).new(:buffer_type => @buffer_type, :log => log) rescue => e $log.warn "#{@store_as} not found. Use 'text' instead" @compressor = TextCompressor.new end @compressor.configure(conf) - @compressor.buffer_type = @buffer_type # TODO: use Plugin.new_formatter instead of TextFormatter.create conf['format'] = @format @formatter = TextFormatter.create(conf) @@ -137,23 +136,29 @@ def check_apikeys @bucket.empty? rescue AWS::S3::Errors::NoSuchBucket # ignore NoSuchBucket Error because ensure_bucket checks it. - rescue - raise "can't call S3 API. Please check your aws_key_id / aws_sec_key or s3_region configuration" + rescue => e + raise "can't call S3 API. Please check your aws_key_id / aws_sec_key or s3_region configuration. error = #{e.inspect}" end class Compressor include Configurable + def initialize(opts = {}) + super() + @buffer_type = opts[:buffer_type] + @log = opts[:log] + end + + attr_reader :buffer_type, :log + def configure(conf) super end - attr_accessor :buffer_type - def ext end def content_type end @@ -188,10 +193,9 @@ w = Zlib::GzipWriter.new(tmp) chunk.write_to(w) w.close ensure w.close rescue nil - w.unlink rescue nil end end class TextCompressor < Compressor def ext