Sha256: b159bccabebd6c8ef49569a3012b3d1fa396eacba898e951c6e54dfd2204fb12
Contents?: true
Size: 1.06 KB
Versions: 15
Compression:
Stored size: 1.06 KB
Contents
module Timber module Events # The HTTP response event tracks outgoing HTTP request responses. # # @note This event should be installed automatically through probes, # such as the {Probes::ActionControllerLogSubscriber} probe. class HTTPResponse < Timber::Event attr_reader :status, :time_ms, :additions def initialize(attributes) @status = attributes[:status] || raise(ArgumentError.new(":status is required")) @time_ms = attributes[:time_ms] || raise(ArgumentError.new(":time_ms is required")) @additions = attributes[:additions] end def to_hash {status: status, time_ms: time_ms} end alias to_h to_hash def as_json(_options = {}) {:http_response => to_hash} end def message message = "Completed #{status} #{status_description} in #{time_ms}ms" message << " (#{additions.join(" | ".freeze)})" unless additions.empty? message end def status_description Rack::Utils::HTTP_STATUS_CODES[status] end end end end
Version data entries
15 entries across 15 versions & 2 rubygems