Class: RosettAi::Telemetry::JsonLinesWriter
- Inherits:
-
Object
- Object
- RosettAi::Telemetry::JsonLinesWriter
- Defined in:
- lib/rosett_ai/telemetry/json_lines_writer.rb
Overview
Writes telemetry events as JSON Lines (one JSON object per line).
Instance Method Summary collapse
-
#close
Close the underlying IO.
-
#initialize(io:, rotator: nil) ⇒ JsonLinesWriter
constructor
A new instance of JsonLinesWriter.
-
#write(event_hash)
Write a single event as a JSON line.
Constructor Details
#initialize(io:, rotator: nil) ⇒ JsonLinesWriter
Returns a new instance of JsonLinesWriter.
17 18 19 20 |
# File 'lib/rosett_ai/telemetry/json_lines_writer.rb', line 17 def initialize(io:, rotator: nil) @io = io @rotator = rotator end |
Instance Method Details
#close
This method returns an undefined value.
Close the underlying IO.
33 34 35 |
# File 'lib/rosett_ai/telemetry/json_lines_writer.rb', line 33 def close @io.close unless @io == $stderr || @io == $stdout end |
#write(event_hash)
This method returns an undefined value.
Write a single event as a JSON line.
26 27 28 29 |
# File 'lib/rosett_ai/telemetry/json_lines_writer.rb', line 26 def write(event_hash) rotate_if_needed @io.puts(JSON.generate(event_hash)) end |