Sha256: 6537716730b2307d638487e0822e9c6a7d0e4b6e3ccfab06e5f8eb641bbe206c
Contents?: true
Size: 921 Bytes
Versions: 1
Compression:
Stored size: 921 Bytes
Contents
require "active_record" require "nokogiri" require "zeitwerk" loader = Zeitwerk::Loader.for_gem loader.collapse("#{__dir__}/rails_api_logger") loader.ignore("#{__dir__}/generators") loader.setup class RailsApiLogger class Error < StandardError; end def initialize(loggable = nil, skip_request_body: false, skip_response_body: false) @loggable = loggable @skip_request_body = skip_request_body @skip_response_body = skip_response_body end def call(url, request) log = OutboundRequestLog.from_request(request, loggable: @loggable, skip_request_body: @skip_request_body) yield.tap do |response| log.from_response(response, skip_response_body: @skip_response_body) end rescue => e log.response_body = {error: e.message} raise ensure log.ended_at = Time.current log.save! end end ActiveSupport.on_load(:action_controller) do include InboundRequestsLogger end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_api_logger-0.9.0 | lib/rails_api_logger.rb |