Class: EventLogger::Output::IO
- Inherits:
-
Object
- Object
- EventLogger::Output::IO
- Defined in:
- lib/event_logger/output/io.rb
Instance Attribute Summary collapse
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
-
#initialize(stream) ⇒ IO
constructor
A new instance of IO.
- #write(severity, details = {}) ⇒ Object
Constructor Details
#initialize(stream) ⇒ IO
Returns a new instance of IO.
12 13 14 |
# File 'lib/event_logger/output/io.rb', line 12 def initialize(stream) @stream = stream end |
Instance Attribute Details
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
10 11 12 |
# File 'lib/event_logger/output/io.rb', line 10 def stream @stream end |
Instance Method Details
#write(severity, details = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/event_logger/output/io.rb', line 16 def write(severity, details = {}) = (Time.now.to_f * 1000).to_i line = JSON.generate({ generated_at: , severity: severity }.merge(details)) @stream << "#{line}\n" end |