Class: Woodchuck::Agent
- Inherits:
-
Object
- Object
- Woodchuck::Agent
- Defined in:
- lib/woodchuck/agent.rb
Instance Attribute Summary collapse
-
#input_format ⇒ Object
Returns the value of attribute input_format.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#output ⇒ Object
Returns the value of attribute output.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#watcher ⇒ Object
Returns the value of attribute watcher.
-
#watcher_thread ⇒ Object
Returns the value of attribute watcher_thread.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Agent
constructor
A new instance of Agent.
- #inspect ⇒ Object
- #start(blocking = false) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Agent
Returns a new instance of Agent.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/woodchuck/agent.rb', line 14 def initialize(={}) @paths = [:paths] [:log_level] ||= :info @logger = Woodchuck::Logger.new(::STDOUT) @logger.level = [:log_level] @mutex = Mutex.new @output = case [:output] when :zeromq Woodchuck::Output::ZeroMQ.new([:log_level]) when :redis Woodchuck::Output::Redis.new([:log_level]) else Woodchuck::Output::STDOUT.new([:log_level]) end @input_format = case [:input_format] when :json_event Woodchuck::Input::JsonEvent.new else Woodchuck::Input::Plain.new end @watcher = Woodchuck::Watcher.new(self, [:log_level], @input_format, @paths) end |
Instance Attribute Details
#input_format ⇒ Object
Returns the value of attribute input_format.
12 13 14 |
# File 'lib/woodchuck/agent.rb', line 12 def input_format @input_format end |
#logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/woodchuck/agent.rb', line 12 def logger @logger end |
#output ⇒ Object
Returns the value of attribute output.
12 13 14 |
# File 'lib/woodchuck/agent.rb', line 12 def output @output end |
#paths ⇒ Object
Returns the value of attribute paths.
12 13 14 |
# File 'lib/woodchuck/agent.rb', line 12 def paths @paths end |
#watcher ⇒ Object
Returns the value of attribute watcher.
12 13 14 |
# File 'lib/woodchuck/agent.rb', line 12 def watcher @watcher end |
#watcher_thread ⇒ Object
Returns the value of attribute watcher_thread.
12 13 14 |
# File 'lib/woodchuck/agent.rb', line 12 def watcher_thread @watcher_thread end |
Instance Method Details
#inspect ⇒ Object
55 56 57 |
# File 'lib/woodchuck/agent.rb', line 55 def inspect to_s end |
#start(blocking = false) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/woodchuck/agent.rb', line 38 def start(blocking=false) @mutex.synchronize do return if @stop == false @stop = false end @watcher_thread = Thread.new { @watcher.start } @watcher_thread.join if blocking end |
#stop ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/woodchuck/agent.rb', line 47 def stop @mutex.synchronize do return if @stop == true @stop = true end Thread.kill(@watcher_thread) if @watcher_thread end |