Hi, I would like to receive an email, if anywhere in my application a Rails.logger.errror method is triggered. I know about all these exception_notfiers, but Rails.logger.error is triggered without an exception as well in my application and these exception_notfier gems will not catch them. Would be great if anybody could offer me a solution. Thanks a lot in advance. -- Volker -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Gd1COILbW1kJ. For more options, visit https://groups.google.com/groups/opt_out.
On Sat, Jan 12, 2013 at 6:47 AM, vhochstein <vhochstein-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi, > > I would like to receive an email, if anywhere in my application a > Rails.logger.errror method is triggered. > > I know about all these exception_notfiers, but Rails.logger.error is > triggered without an exception as well in my application and these > exception_notfier gems will not catch them.This is indeed an issue. Currently, our app logs to the standard Rails logger sometimes, and to Data Dog sometimes -- these require two different calls, and it is sometimes confusing when to use which. This shouldn''t be too much of a problem, since you can specify a new logger for Rails.logger to use (and use per environment, if wanted). As for having an email option, log4r seems more useful. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Jan 12, 1:47 pm, vhochstein <vhochst...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi, > > I would like to receive an email, if anywhere in my application a > Rails.logger.errror method is triggered. > > I know about all these exception_notfiers, but Rails.logger.error is > triggered without an exception as well in my application and these > exception_notfier gems will not catch them. > > Would be great if anybody could offer me a solution.We used to do this via syslog - our hosting provider had a shell script that tailed the syslog file containing entries relative to our app and would email us anything of that level or above. I''m afraid that was with a previous job so I no longer have access to that but it is definitely doable Fred.> > Thanks a lot in advance. > > -- > Volker-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
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. Am Samstag, 12. Januar 2013 13:47:12 UTC+1 schrieb vhochstein:> > Hi, > > I would like to receive an email, if anywhere in my application a > Rails.logger.errror method is triggered. > > I know about all these exception_notfiers, but Rails.logger.error is > triggered without an exception as well in my application and these > exception_notfier gems will not catch them. > > Would be great if anybody could offer me a solution. > > Thanks a lot in advance. > > -- > Volker >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/FOmyPjD7GocJ. For more options, visit https://groups.google.com/groups/opt_out.
On Sun, Jan 13, 2013 at 5:42 AM, Crispin Schäffler <crispinschaeffler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Yeah, as I told, i don''t know the insides of the error method or the correct specification.. Just wanted to give a hint how you could do it to get it to work quickly and without much trouble. And in my opinion its not that dirty to alias a function if you know what you do. Sure you can use a block to do the mailing. Am Sonntag, 13. Januar 2013 13:00:50 UTC+1 schrieb Jordon Bedwell:> > On Sun, Jan 13, 2013 at 5:42 AM, Crispin Schäffler > <crispins...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/K29Qcs73qk0J. For more options, visit https://groups.google.com/groups/opt_out.
Just wanted to give a hint that it''s not that hard to make it work. Your approach is much cleaner and should be used of course. Am Sonntag, 13. Januar 2013 13:00:50 UTC+1 schrieb Jordon Bedwell:> > On Sun, Jan 13, 2013 at 5:42 AM, Crispin Schäffler > <crispins...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Ao3o2brzhHUJ. For more options, visit https://groups.google.com/groups/opt_out.
On Sun, Jan 13, 2013 at 6:06 AM, Crispin Schäffler <crispinschaeffler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yeah, as I told, i don''t know the insides of the error method or the correct > specification.. Just wanted to give a hint how you could do it to get it to > work quickly and without much trouble. > > And in my opinion its not that dirty to alias a function if you know what > you do. > Sure you can use a block to do the mailing.Until Joe down the street decides he wants to be as clever as you and alias it to old_method and erase yours accidently, or until Marline from up the street asks you why there are objects hanging around when you mean to replace them. If you intend for :old_method to be an object on it''s parent then great more power to you, if you don''t then unbind the method and use define_method and be cleaner in your source even if you are already being dirty by monkey patching. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.