Skip to content

Commit 4182190

Browse files
committed
fix to get flush_interval > 0 working
1 parent 1585c27 commit 4182190

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/logstash/outputs/file.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# }
1919
class LogStash::Outputs::File < LogStash::Outputs::Base
2020
concurrency :shared
21-
21+
2222
FIELD_REF = /%\{[^}]+\}/
2323

2424
config_name "file"
@@ -48,7 +48,7 @@ class LogStash::Outputs::File < LogStash::Outputs::Base
4848
# into this file and inside the defined path.
4949
config :filename_failure, :validate => :string, :default => '_filepath_failures'
5050

51-
# If the configured file is deleted, but an event is handled by the plugin,
51+
# If the configured file is deleted, but an event is handled by the plugin,
5252
# the plugin will recreate the file. Default => true
5353
config :create_if_deleted, :validate => :boolean, :default => true
5454

@@ -82,7 +82,7 @@ def register
8282

8383
@files = {}
8484
@io_mutex = Mutex.new
85-
85+
8686
@path = File.expand_path(path)
8787

8888
validate_path
@@ -141,18 +141,18 @@ def multi_receive_encoded(events_and_encoded)
141141
# append to the file
142142
chunks.each {|chunk| fd.write(chunk) }
143143
end
144-
fd.flush
144+
flush(fd)
145145
end
146-
146+
147147
close_stale_files
148-
end
148+
end
149149
end # def receive
150150

151151
public
152152
def close
153153
@io_mutex.synchronize do
154154
@logger.debug("Close: closing files")
155-
155+
156156
@files.each do |path, fd|
157157
begin
158158
fd.close
@@ -180,8 +180,8 @@ def event_path(event)
180180
file_output_path = @failure_path
181181
end
182182
@logger.debug("File, writing event to file.", :filename => file_output_path)
183-
184-
file_output_path
183+
184+
file_output_path
185185
end
186186

187187
private
@@ -219,7 +219,7 @@ def flush_pending_files
219219
@logger.debug("Flushing file", :path => path, :fd => fd)
220220
fd.flush
221221
end
222-
222+
223223
@last_flush_cycle = Time.now
224224
end
225225

@@ -268,7 +268,7 @@ def open(path)
268268
end
269269

270270
@logger.info("Opening file", :path => path)
271-
271+
272272
dir = File.dirname(path)
273273
if !Dir.exist?(dir)
274274
@logger.info("Creating directory", :directory => dir)
@@ -278,7 +278,7 @@ def open(path)
278278
FileUtils.mkdir_p(dir)
279279
end
280280
end
281-
281+
282282
# work around a bug opening fifos (bug JRUBY-6280)
283283
stat = File.stat(path) rescue nil
284284
if stat && stat.ftype == "fifo" && LogStash::Environment.jruby?

0 commit comments

Comments
 (0)