Critical Error Management: Registration and Email

What's the best way to send fast, one-line emails to an administrative address in Rails?

I use Rails Loggerto track unpleasant issues in my application. One of my controllers is doing critical work, and I need to know any errors as soon as possible. When there is an error, I want my application to send me an email, paying attention to the journal containing more detailed information. I envision something like the following pseudocode:

begin
   ...
rescue
   logger.error("Found an error!  Params hash is " + params.to_s)
   email("user@example.com","Critical error in log.  Investigate line " + len(logger.error).to_s)
end

The obvious first place I looked at was ActionMailer . However, both the documentation and my literature talk about creating a model, view and mail controller that seems too complicated for what I want: a very short (single-line) email to the email address, where formatting and reply to the address irrelevant. This brings me back to my question: what's the best way to send fast, single-line emails to an administrative email address in Rails?

+3
source share
2 answers

Pony gem ( Pony Express), ActionMailer:

require 'pony'
Pony.mail(:to => 'user@example.com', :from => 'railsapp@example.com',
          :subject => 'Critical error in log')

, Hoptoad . .

+4

Source: https://habr.com/ru/post/1728960/


All Articles