Sha256: 1a0e16a11ae186bcc2f20b2458ca9262dec449288a1289cf2cb30b888eda8d85
Contents?: true
Size: 1.13 KB
Versions: 6
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 HTTPServerResponse < 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
6 entries across 6 versions & 1 rubygems