Class: StructuredEventLogger::JsonWriter
- Inherits:
-
Object
- Object
- StructuredEventLogger::JsonWriter
- Defined in:
- lib/structured_event_logger/json_writer.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
- #call(scope, event, hash, record) ⇒ Object
-
#initialize(io) ⇒ JsonWriter
constructor
A new instance of JsonWriter.
Constructor Details
#initialize(io) ⇒ JsonWriter
Returns a new instance of JsonWriter.
7 8 9 |
# File 'lib/structured_event_logger/json_writer.rb', line 7 def initialize(io) @io = io end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
5 6 7 |
# File 'lib/structured_event_logger/json_writer.rb', line 5 def io @io end |
Instance Method Details
#call(scope, event, hash, record) ⇒ Object
11 12 13 |
# File 'lib/structured_event_logger/json_writer.rb', line 11 def call(scope, event, hash, record) io.write(ActiveSupport::JSON.encode(record) + "\n") end |