Class: Hallmonitor::Outputter
- Inherits:
-
Object
- Object
- Hallmonitor::Outputter
- Defined in:
- lib/hallmonitor/outputter.rb
Direct Known Subclasses
Hallmonitor::Outputters::IOOutputter, Hallmonitor::Outputters::NewRelic, Hallmonitor::Outputters::StatsdOutputter
Constant Summary collapse
- @@outputters =
Array.new
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.add_outputter(outputter) ⇒ Object
Adds an outputter.
-
.output(event) ⇒ Object
Outputs the event via each configured outputter.
-
.outputters ⇒ Object
Returns the current list of outputters.
Instance Method Summary collapse
-
#initialize(name) ⇒ Outputter
constructor
A new instance of Outputter.
-
#process(event) ⇒ Object
Processes and event.
Constructor Details
#initialize(name) ⇒ Outputter
Returns a new instance of Outputter.
6 7 8 9 |
# File 'lib/hallmonitor/outputter.rb', line 6 def initialize(name) raise(ArgumentError, "Outputter expects a name") if name.nil? @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/hallmonitor/outputter.rb', line 3 def name @name end |
Class Method Details
.add_outputter(outputter) ⇒ Object
Adds an outputter. Outputters are required to respond to :process
19 20 21 |
# File 'lib/hallmonitor/outputter.rb', line 19 def self.add_outputter(outputter) @@outputters << outputter if outputter.respond_to?(:process) end |
.output(event) ⇒ Object
Outputs the event via each configured outputter
25 26 27 28 29 |
# File 'lib/hallmonitor/outputter.rb', line 25 def self.output(event) @@outputters.each do |o| o.process(event) end end |
.outputters ⇒ Object
Returns the current list of outputters
13 14 15 |
# File 'lib/hallmonitor/outputter.rb', line 13 def self.outputters @@outputters end |
Instance Method Details
#process(event) ⇒ Object
Processes and event. Child classes should implement this to output events
33 34 35 |
# File 'lib/hallmonitor/outputter.rb', line 33 def process(event) # Nothing end |