8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/filewatch/ext/filetail.rb', line 8
def subscribe(&block)
@watch.subscribe(@opts[:stat_interval],
@opts[:discover_interval]) do |event, path|
case event
when :create, :create_initial
if @files.member?(path)
@logger.debug("#{event} for #{path}: already exists in @files")
next
end
if _open_file(path, event)
_read_file(path, &block)
end
when :modify
_open_file(path, event) if @opts[:eof_close]
if !@files.member?(path)
@logger.debug(":modify for #{path}, does not exist in @files")
if _open_file(path, event)
_read_file(path, &block)
end
else
_read_file(path, &block)
end
when :delete
@logger.debug(":delete for #{path}, deleted from @files")
_read_file(path, &block) if !@opts[:eof_close]
_progressdb_delete(path, &block) if @opts[:progressdb] && @opts[:progressdb_del]
@files[path].close if !@opts[:eof_close]
@files.delete(path)
_sincedb_delete(path)
@statcache.delete(path)
else
@logger.warn("unknown event type #{event} for #{path}")
end
end end
|