Module: EventStore::HTTP::Session::LogText
- Defined in:
- lib/event_store/http/session/log_text.rb
Class Method Summary collapse
- .body_data(message) ⇒ Object
- .header_data(message) ⇒ Object
- .request(request, response = nil) ⇒ Object
Class Method Details
.body_data(message) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/event_store/http/session/log_text.rb', line 33 def self.body_data() if .body.to_s.empty? '(no body)' else .body end end |
.header_data(message) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/event_store/http/session/log_text.rb', line 15 def self.header_data() text = String.new if ['host'] text << "host: #{['host']}\n" end .each_header do |name, value| next if name == 'host' text << "#{name}: #{value}\n" end text << "(no headers)" if text.empty? text end |
.request(request, response = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/event_store/http/session/log_text.rb', line 5 def self.request(request, response=nil) text = %[Action: #{request.method}, Path: #{request.path}, RequestLength: #{request.body&.bytesize.to_i}] unless response.nil? text << %[, StatusCode: #{response.code}, ReasonPhrase: #{response.}, ResponseLength: #{response.body&.bytesize.to_i}] end text end |