18
18
# }
19
19
class LogStash ::Outputs ::File < LogStash ::Outputs ::Base
20
20
concurrency :shared
21
-
21
+
22
22
FIELD_REF = /%\{ [^}]+\} /
23
23
24
24
config_name "file"
@@ -48,7 +48,7 @@ class LogStash::Outputs::File < LogStash::Outputs::Base
48
48
# into this file and inside the defined path.
49
49
config :filename_failure , :validate => :string , :default => '_filepath_failures'
50
50
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,
52
52
# the plugin will recreate the file. Default => true
53
53
config :create_if_deleted , :validate => :boolean , :default => true
54
54
@@ -82,7 +82,7 @@ def register
82
82
83
83
@files = { }
84
84
@io_mutex = Mutex . new
85
-
85
+
86
86
@path = File . expand_path ( path )
87
87
88
88
validate_path
@@ -141,18 +141,18 @@ def multi_receive_encoded(events_and_encoded)
141
141
# append to the file
142
142
chunks . each { |chunk | fd . write ( chunk ) }
143
143
end
144
- fd . flush
144
+ flush ( fd )
145
145
end
146
-
146
+
147
147
close_stale_files
148
- end
148
+ end
149
149
end # def receive
150
150
151
151
public
152
152
def close
153
153
@io_mutex . synchronize do
154
154
@logger . debug ( "Close: closing files" )
155
-
155
+
156
156
@files . each do |path , fd |
157
157
begin
158
158
fd . close
@@ -180,8 +180,8 @@ def event_path(event)
180
180
file_output_path = @failure_path
181
181
end
182
182
@logger . debug ( "File, writing event to file." , :filename => file_output_path )
183
-
184
- file_output_path
183
+
184
+ file_output_path
185
185
end
186
186
187
187
private
@@ -219,7 +219,7 @@ def flush_pending_files
219
219
@logger . debug ( "Flushing file" , :path => path , :fd => fd )
220
220
fd . flush
221
221
end
222
-
222
+
223
223
@last_flush_cycle = Time . now
224
224
end
225
225
@@ -268,7 +268,7 @@ def open(path)
268
268
end
269
269
270
270
@logger . info ( "Opening file" , :path => path )
271
-
271
+
272
272
dir = File . dirname ( path )
273
273
if !Dir . exist? ( dir )
274
274
@logger . info ( "Creating directory" , :directory => dir )
@@ -278,7 +278,7 @@ def open(path)
278
278
FileUtils . mkdir_p ( dir )
279
279
end
280
280
end
281
-
281
+
282
282
# work around a bug opening fifos (bug JRUBY-6280)
283
283
stat = File . stat ( path ) rescue nil
284
284
if stat && stat . ftype == "fifo" && LogStash ::Environment . jruby?
0 commit comments