286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
# File 'lib/fluent/plugin/in_tail.rb', line 286
def expand_paths
date = Fluent::EventTime.now
paths = []
@paths.each { |path|
path = if @path_timezone
@path_formatters[path].call(date)
else
date.to_time.strftime(path)
end
if path.include?('*')
paths += Dir.glob(path).select { |p|
begin
is_file = !File.directory?(p)
if (File.readable?(p) || have_read_capability?) && is_file
if @limit_recently_modified && File.mtime(p) < (date.to_time - @limit_recently_modified)
false
else
true
end
else
if is_file
unless @ignore_list.include?(p)
log.warn "#{p} unreadable. It is excluded and would be examined next time."
@ignore_list << p if @ignore_repeated_permission_error
end
end
false
end
rescue Errno::ENOENT, Errno::EACCES
log.debug("#{p} is missing after refresh file list")
false
end
}
else
paths << path
end
}
excluded = @exclude_path.map { |path|
path = if @path_timezone
@exclude_path_formatters[path].call(date)
else
date.to_time.strftime(path)
end
path.include?('*') ? Dir.glob(path) : path
}.flatten.uniq
hash = {}
(paths - excluded).select { |path|
FileTest.exist?(path)
}.each { |path|
begin
target_info = TargetInfo.new(path, Fluent::FileWrapper.stat(path).ino)
if @follow_inodes
hash[target_info.ino] = target_info
else
hash[target_info.path] = target_info
end
rescue Errno::ENOENT, Errno::EACCES => e
$log.warn "expand_paths: stat() for #{path} failed with #{e.class.name}. Skip file."
end
}
hash
end
|