Class: RaceGuard::Reporters::JsonReporter
- Inherits:
-
Object
- Object
- RaceGuard::Reporters::JsonReporter
- Defined in:
- lib/race_guard/reporters/json_reporter.rb
Overview
One JSON object per line (newline-delimited JSON) to the given IO.
Instance Method Summary collapse
-
#initialize(io = $stderr) ⇒ JsonReporter
constructor
A new instance of JsonReporter.
- #report(event) ⇒ Object
Constructor Details
#initialize(io = $stderr) ⇒ JsonReporter
Returns a new instance of JsonReporter.
9 10 11 12 |
# File 'lib/race_guard/reporters/json_reporter.rb', line 9 def initialize(io = $stderr) @io = io @io_mutex = Mutex.new end |
Instance Method Details
#report(event) ⇒ Object
14 15 16 17 |
# File 'lib/race_guard/reporters/json_reporter.rb', line 14 def report(event) line = JSON.generate(event.to_h) @io_mutex.synchronize { @io.puts(line) } end |