Class: Radar::Reporter::IoReporter
- Inherits:
-
Object
- Object
- Radar::Reporter::IoReporter
- Defined in:
- lib/radar/reporter/io_reporter.rb
Overview
A reporter which simply dumps the event JSON out to some IO object. If you're outputting to a file, you should look into FileReporter instead, which will automatically create unique filenames per exception.
Some uses for this reporter:
- Output to
stderr
, since a process'sstderr
may be redirected to a log file already. - Output to
stdout
, just for testing. - Output to some network IO stream to talk to a server across a network.
Instance Attribute Summary collapse
-
#io_object ⇒ Object
Returns the value of attribute io_object.
Instance Method Summary collapse
-
#initialize(opts = nil) ⇒ IoReporter
constructor
A new instance of IoReporter.
- #report(event) ⇒ Object
Constructor Details
#initialize(opts = nil) ⇒ IoReporter
Returns a new instance of IoReporter.
19 20 21 22 23 |
# File 'lib/radar/reporter/io_reporter.rb', line 19 def initialize(opts=nil) (opts || {}).each do |k,v| send("#{k}=", v) end end |
Instance Attribute Details
#io_object ⇒ Object
Returns the value of attribute io_object.
17 18 19 |
# File 'lib/radar/reporter/io_reporter.rb', line 17 def io_object @io_object end |
Instance Method Details
#report(event) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/radar/reporter/io_reporter.rb', line 25 def report(event) return if !io_object raise ArgumentError.new("IoReporter `io_object` must be an IO object.") if !io_object.is_a?(IO) # Straight push the object to the object and flush immediately io_object.puts(event.to_json) io_object.flush end |