lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-0.3.3 vs lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-0.3.4

- old
+ new

@@ -75,10 +75,21 @@ when 'json' then ['json', 'application/json'] else ['txt', 'text/plain'] end @timef = TimeFormatter.new(@time_format, @localtime) + + if @localtime + @path_slicer = Proc.new {|path| + Time.now.strftime(path) + } + else + @path_slicer = Proc.new {|path| + Time.now.utc.strftime(path) + } + end + end def start super options = {} @@ -119,11 +130,12 @@ def write(chunk) i = 0 begin + path = @path_slicer.call(@path) values_for_s3_object_key = { - "path" => @path, + "path" => path, "time_slice" => chunk.key, "file_extension" => @ext, "index" => i } s3path = @s3_object_key_format.gsub(%r(%{[^}]+})) { |expr|