Sha256: 0a8f6c857d64b0d732cd2d397e870809a322ea5d3d9c2dabc5c9012ffb3ffbc1
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
require "action_dispatch/middleware/debug_exceptions" module GovukLogging module RailsExt module ActionDispatch def self.should_monkey_patch_log_error?(clazz = ::ActionDispatch::DebugExceptions) empty_instance = clazz.new nil target_method = empty_instance.method :log_error expected_parameters = [%i[req request], %i[req wrapper]] actual_parameters = target_method.parameters should_monkey_patch = actual_parameters == expected_parameters unless should_monkey_patch Rails.logger.warn "Refused to monkey patch ::ActionDispatch::DebugExceptions#log_error - " + "signatures do not match. " + "Expected #{expected_parameters}, but got #{actual_parameters}" end should_monkey_patch rescue StandardError => ex Rails.logger.warn "Failed to detect whether to monkey patch " + "::ActionDispatch::DebugExceptions#log_error - #{ex.inspect}" false end def self.monkey_patch_log_error(clazz = ::ActionDispatch::DebugExceptions) clazz.class_eval do private def log_error(request, wrapper) logger = logger(request) return unless logger exception = wrapper.exception trace = wrapper.application_trace trace = wrapper.framework_trace if trace.empty? logger.fatal({ exception_class: exception.class.to_s, exception_message: exception.message, stacktrace: trace, }.to_json) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
govuk_app_config-2.2.0 | lib/govuk_app_config/rails_ext/action_dispatch/debug_exceptions.rb |