Sunday, January 13, 2013

Re: [Rails] Re: Send mail on Rails.logger.error

On Sun, Jan 13, 2013 at 5:42 AM, Crispin Schäffler
<crispinschaeffler@gmail.com> wrote:
> I don't really know that much about the interns of Rails.logger.error method
> but how about overwriting it for your app?
>
> use alias on the old method and do something like this:
> alias :old_error :error
>
> def error
> # send your mail or whatever
> old_error
> end
>
> would at least do its job without braking all the stuff the logger does.

Uhm, you guys do know that you do not have to resort to such dirty
tactics? Read:

Rails.logger.error do
"There was an error".tap do |s|
# Do mailing Work Here
end
end

cat log/development.log
There was an error

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate