Class: Reacter::LoggerAgent
Instance Attribute Summary
Attributes inherited from Agent
Instance Method Summary collapse
-
#initialize ⇒ LoggerAgent
constructor
A new instance of LoggerAgent.
- #received(message) ⇒ Object
Methods inherited from Agent
Constructor Details
#initialize ⇒ LoggerAgent
Returns a new instance of LoggerAgent.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/reacter/agents/logger.rb', line 8 def initialize() super case @config.get(:file, 'stdout') when 'stderr' @stream = STDERR when 'stdout' @stream = STDOUT else @stream = File.open(File.(@config.get(:file)), 'a+') end @output_format = @config.get(:format) end |
Instance Method Details
#received(message) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/reacter/agents/logger.rb', line 23 def received() if @output_format.nil? line = "logger: [#{message.state or :unknown}] #{message.source}/#{message.metric} = #{message.value}" else line = Message.dump(, @output_format) end @stream.puts(line) @stream.flush() end |