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