Class: Ingenico::Direct::SDK::Logging::ResponseLogMessageBuilder
- Inherits:
-
LogMessageBuilder
- Object
- LogMessageBuilder
- Ingenico::Direct::SDK::Logging::ResponseLogMessageBuilder
- Defined in:
- lib/ingenico/direct/sdk/logging/response_log_message_builder.rb
Instance Attribute Summary
Attributes inherited from LogMessageBuilder
#body, #content_type, #headers, #request_id
Instance Method Summary collapse
-
#get_message ⇒ Object
Constructs and returns a log message based on the request data.
-
#initialize(request_id, status_code, duration = -1)) ⇒ ResponseLogMessageBuilder
constructor
Class that converts data about a response into a properly formatted log message.
Methods inherited from LogMessageBuilder
#add_headers, #set_body, #to_s
Constructor Details
#initialize(request_id, status_code, duration = -1)) ⇒ ResponseLogMessageBuilder
Class that converts data about a response into a properly formatted log message. Formats request id, status code, headers, body and time between request and response into a helpful message.
12 13 14 15 16 |
# File 'lib/ingenico/direct/sdk/logging/response_log_message_builder.rb', line 12 def initialize(request_id, status_code, duration = -1) super(request_id) @status_code = status_code @duration = duration end |
Instance Method Details
#get_message ⇒ Object
Constructs and returns a log message based on the request data. The log message is a string.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ingenico/direct/sdk/logging/response_log_message_builder.rb', line 19 def msg_template = "Incoming response (requestId=\"%s\"#{(@duration.positive?) ? ", %.3f ms" : ""}):\n" + " status-code: \"%s\"\n" + " headers: \"%s\"\n" + " content-type: \"%s\"\n" + " body: \"%s\"" @duration.positive? ? sprintf(msg_template, @request_id, @duration, @status_code, @headers, empty_if_null(@content_type), empty_if_null(@body)) : sprintf(msg_template, @request_id, @status_code, @headers, empty_if_null(@content_type), empty_if_null(@body)) end |