Sha256: b70919b8b3169c250c29cbb070040cd2855a3c7eb82742aab02960a655828823
Contents?: true
Size: 1.13 KB
Versions: 9
Compression:
Stored size: 1.13 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")) @time_ms = @time_ms.round(6) @additions = attributes[:additions] end def to_hash {status: status, time_ms: time_ms} end alias to_h to_hash def as_json(_options = {}) {:server_side_app => {:http_server_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
9 entries across 9 versions & 1 rubygems