Class: Rack::TrafficLogger::StreamSimulator

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/traffic_logger/stream_simulator.rb

Instance Method Summary collapse

Constructor Details

#initialize(color: false, pretty_print: false) ⇒ StreamSimulator

Returns a new instance of StreamSimulator.



7
8
9
10
# File 'lib/rack/traffic_logger/stream_simulator.rb', line 7

def initialize(color: false, pretty_print: false)
  @color = color
  @pretty_print = pretty_print
end

Instance Method Details

#format(input) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/rack/traffic_logger/stream_simulator.rb', line 12

def format(input)
  case input['event']
    when 'request' then format_request input
    when 'response' then format_response input
    else ''
  end.tap do |result|
    result << format_exception(input['logger_exception']) if input.key? 'logger_exception'
  end
end