Sha256: e3adb34140997a9c0f9ff22ffd4816ff71ba98d277f809dcc6b2c6b6dd37b593
Contents?: true
Size: 962 Bytes
Versions: 17
Compression:
Stored size: 962 Bytes
Contents
require "savon/log_message" module Savon class RequestLogger def initialize(globals) @globals = globals end def log(request, &http_request) log_request(request) if log? response = http_request.call log_response(response) if log? response end def logger @globals[:logger] end def log? @globals[:log] end private def log_request(request) logger.info "SOAP request: #{request.url}" logger.info headers_to_log(request.headers) logger.debug body_to_log(request.body) end def log_response(response) logger.info "SOAP response (status #{response.code})" logger.debug body_to_log(response.body) end def headers_to_log(headers) headers.map { |key, value| "#{key}: #{value}" }.join(", ") end def body_to_log(body) LogMessage.new(body, @globals[:filters], @globals[:pretty_print_xml]).to_s end end end
Version data entries
17 entries across 17 versions & 3 rubygems