Class: EventLoggerRails::Output
- Inherits:
- 
      Object
      
        - Object
- EventLoggerRails::Output
 
- Defined in:
- lib/event_logger_rails/output.rb
Overview
Merges data from application, request, and logger message for structured output
Instance Method Summary collapse
- 
  
    
      #initialize(level:, timestamp:, message:)  ⇒ Output 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Output. 
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(level:, timestamp:, message:) ⇒ Output
Returns a new instance of Output.
| 7 8 9 10 11 12 | # File 'lib/event_logger_rails/output.rb', line 7 def initialize(level:, timestamp:, message:) @current_request = EventLoggerRails::CurrentRequest @level = level @timestamp = .iso8601(3) @message = .respond_to?(:to_hash) ? sanitizer.filter(**) : { message: } end | 
Instance Method Details
#to_hash ⇒ Object
| 18 19 20 | # File 'lib/event_logger_rails/output.rb', line 18 def to_hash application_data.merge(**current_request_data, **logger_data) end | 
#to_json(*args) ⇒ Object
| 14 15 16 | # File 'lib/event_logger_rails/output.rb', line 14 def to_json(*args) JSON.generate(to_hash, *args) end |