Skip to content

Commit

Permalink
Patch ActionDispatch::DebugExceptions
Browse files Browse the repository at this point in the history
publish errors to Notifications instead of logging the full backtrace directly.
  • Loading branch information
wjordan committed Aug 11, 2018
1 parent 0e1ed04 commit e2b703a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/lograge.rb
Expand Up @@ -117,6 +117,7 @@ def unsubscribe(component, subscriber)
end

def setup(app)
require 'lograge/rails_ext/action_dispatch/debug_exceptions'
self.application = app
disable_rack_cache_verbose_output
keep_original_rails_log
Expand Down
1 change: 1 addition & 0 deletions lib/lograge/log_subscriber.rb
Expand Up @@ -15,6 +15,7 @@ def process_action(event)
formatted_message = Lograge.formatter.call(data)
logger.send(Lograge.log_level, formatted_message)
end
alias process_exception process_action

def redirect_to(event)
RequestStore.store[:lograge_location] = event.payload[:location]
Expand Down
17 changes: 17 additions & 0 deletions lib/lograge/rails_ext/action_dispatch/debug_exceptions.rb
@@ -0,0 +1,17 @@
require 'action_dispatch/middleware/debug_exceptions'

module Lograge
module DebugExceptions
def log_error(request, wrapper)
payload = {
path: request.fullpath,
method: request.method,
format: request.format.ref,
exception: [wrapper.exception.class.name, wrapper.exception.message]
}
ActiveSupport::Notifications.instrument 'process_exception.action_controller', payload
super(request, wrapper) if lograge_config.keep_original_rails_log
end
end
ActionDispatch::DebugExceptions.prepend DebugExceptions
end

0 comments on commit e2b703a

Please sign in to comment.