We have exception notifier set up on our server, though would like a back-up solution, if the email server is down, that would let us log exceptions in the database.
How is exception notifier listening to every method call and can I listen too?
Or.. is there a gem that already does both sending emails and logging to the database for exceptions?
Your best bet, using Exception Notifier, would be to use rescue_from
within your ApplicationController
looking for all exceptions, then do bother your logging and a manual call to Exception Notifier.
Example:
class ApplicationController < ActionController::Base
rescue_from Exception, :with => :log_and_notify
def log_and_notify(error)
# Save to the DB
# This manual call example is straight from the Exception Notifier github page.
ExceptionNotifier::Notifier.exception_notification(request.env, exception, :data => {:message => "was doing something wrong"}).deliver
end
end
So if a controller gets an error during one of it's actions, it will go to this method, and you can save it to the DB before delivering the email.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.