Class: Woodchuck::Watcher

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/woodchuck/watcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent, log_level, input_format, *paths) ⇒ Watcher

Returns a new instance of Watcher.



17
18
19
20
21
22
23
# File 'lib/woodchuck/watcher.rb', line 17

def initialize(agent, log_level, input_format, *paths)
  @agent = agent
  @logger = Woodchuck::Logger.new(::STDOUT)
@logger.level = log_level unless log_level.nil?
  @paths = paths.flatten.compact
@input_format = input_format
end

Instance Attribute Details

#agentObject

Returns the value of attribute agent.



14
15
16
# File 'lib/woodchuck/watcher.rb', line 14

def agent
  @agent
end

#eventsObject

Returns the value of attribute events.



14
15
16
# File 'lib/woodchuck/watcher.rb', line 14

def events
  @events
end

#input_formatObject

Returns the value of attribute input_format.



14
15
16
# File 'lib/woodchuck/watcher.rb', line 14

def input_format
  @input_format
end

#loggerObject

Returns the value of attribute logger.



14
15
16
# File 'lib/woodchuck/watcher.rb', line 14

def logger
  @logger
end

#pathsObject

Returns the value of attribute paths.



14
15
16
# File 'lib/woodchuck/watcher.rb', line 14

def paths
  @paths
end

Instance Method Details

#inspectObject



35
36
37
# File 'lib/woodchuck/watcher.rb', line 35

def inspect
  to_s
end

#startObject



25
26
27
28
29
30
31
32
33
# File 'lib/woodchuck/watcher.rb', line 25

def start
Woodchuck::TailReader.static_init(input_format, output)

EventMachine.run do
	paths.each do |path|
		EventMachine::FileGlobWatchTail.new(path, Woodchuck::TailReader)
	end
end
end