lib/fluent/plugin/buf_file.rb in fluentd-0.10.28 vs lib/fluent/plugin/buf_file.rb in fluentd-0.10.29

- old
+ new

@@ -93,10 +93,16 @@ @buffer_path_suffix = @buffer_path[pos+1..-1] else @buffer_path_prefix = @buffer_path+"." @buffer_path_suffix = ".log" end + + if flush_at_shutdown = conf['flush_at_shutdown'] + @flush_at_shutdown = true + else + @flush_at_shutdown = false + end end def start FileUtils.mkdir_p File.dirname(@buffer_path_prefix+"path") super @@ -158,9 +164,21 @@ encoded_key = m ? m[1] : "" tsuffix = m[3] npath = "#{@buffer_path_prefix}#{encoded_key}.q#{tsuffix}#{@buffer_path_suffix}" chunk.mv(npath) + end + + def before_shutdown(out) + if @flush_at_shutdown + synchronize do + @map.each_key {|key| + push(key) + } + while pop(out) + end + end + end end protected def encode_key(key) URI.escape(key, /[^-_.a-zA-Z0-9]/n)