Hi, I don''t understand how we can just call ''logger'' from any method, but when using observers we have to have it attached to some kind of object (usually the model of the object being observed). Why is that? What is logger exactly? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 30, 9:08 pm, Steve Dogers <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, I don''t understand how we can just call ''logger'' from any method,You can''t call it from any method. ActionController::Base, ActiveRecord::Base and a few others have accessors called logger that returns a Logger object so whenever you''re in an instance method of an ActiveRecord::Base subclass you can call it (class methods too - the accessor is defined on those classes as well). If the object you''re writing a method for doesn''t have a logger method then you can''t call logger, if it does you can. Fred> but when using observers we have to have it attached to some kind of > object (usually the model of the object being observed). Why is that? > What is logger exactly?> -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 30, 1:32 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You can''t call it from any method. ActionController::Base, > ActiveRecord::Base and a few others have accessors called logger that > returns a Logger objectRails also stores a Logger object in RAILS_DEFAULT_LOGGER, so you can for instance get access to it in testing by including something this simple in /test/test_helper.rb: def logger RAILS_DEFAULT_LOGGER end There may be far better ways to find why tests fail, but tossing in some logger.info("wonky_var value: #{wonky_var}") calls in unit/functional tests and watching what shows up in /log/ test.log is pretty 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
i find I cant send to logger in production mode if I am running a script/runner on a model method. Works in development mode, must be a reason for this although I cant figure it Output just seems to go nowhere Tonypm --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---