Module: LogStruct::Integrations::RackErrorHandler
- Extended by:
- IntegrationInterface, T::Sig
- Defined in:
- lib/log_struct/integrations/rack_error_handler.rb,
lib/log_struct/integrations/rack_error_handler/middleware.rb,
lib/log_struct/integrations/rack_error_handler/error_lines.rb,
lib/log_struct/integrations/rack_error_handler/parse_error_logging.rb,
lib/log_struct/integrations/rack_error_handler/debug_exceptions_logging.rb
Overview
Rack middleware integration for structured logging
Defined Under Namespace
Modules: DebugExceptionsLogging, ErrorLines, ParseErrorLogging Classes: Middleware
Class Method Summary collapse
-
.setup(config) ⇒ Boolean?
Set up structured lines for CSRF and IP spoofing errors, errors the app didn't handle, and errors that get past ShowExceptions.
Methods included from IntegrationInterface
Class Method Details
.setup(config) ⇒ Boolean?
Set up structured lines for CSRF and IP spoofing errors, errors the app didn't handle, and errors that get past ShowExceptions
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/log_struct/integrations/rack_error_handler.rb', line 23 def self.setup(config) return nil unless RackSetup.enabled?(config) # Errors from the middleware outside ShowExceptions, and any that get past it RackSetup.insert_before( ::ActionDispatch::RemoteIp, Integrations::RackErrorHandler::Middleware ) # DebugExceptions calls its interceptors with each error from the app (in every environment), # before ShowExceptions turns it into Rails' usual response: 422 for a CSRF error unless @interceptor_registered ::ActionDispatch::DebugExceptions.register_interceptor(ErrorLines.method(:intercept)) @interceptor_registered = true end # An error line instead of the text Rails logs for an error the app didn't handle unless ::ActionDispatch::DebugExceptions <= DebugExceptionsLogging ::ActionDispatch::DebugExceptions.prepend(DebugExceptionsLogging) end # The size of a body Rails can't parse, instead of the body ::ActionDispatch::Request.prepend(ParseErrorLogging) unless ::ActionDispatch::Request <= ParseErrorLogging true end |