Sha256: 7a4cb8ef8f3be6e49bb902f860b069acda77de12069fa71c0c636a9d08f64634
Contents?: true
Size: 865 Bytes
Versions: 10
Compression:
Stored size: 865 Bytes
Contents
module NxtHttpClient class Logger def initialize(logger) @logger = logger end def call(client, request, _response_handler, fire) started_at = now error = nil result = nil options = { client: client, started_at: started_at, request: request } begin result = fire.call rescue => e error = e options.merge!(error: e) ensure finished_at = now options.merge!( finished_at: now, elapsed_time_in_milliseconds: finished_at - started_at, response: request.response, http_status: request.response&.code ) end logger.call(options) raise error if error result end private attr_reader :logger def now Time.current.to_i * 1000 end end end
Version data entries
10 entries across 10 versions & 1 rubygems