Wins Lin
2013-Jun-14 08:15 UTC
How to instantiate a logger in an Engine only once and then use only that object?
I found this thread: http://www.ruby-forum.com/topic/151906 One commentator says:>To minimize engines polluting our logs, we just changed the logger for >the engines plugin like this:>In engines.rb, update the logger method:> def logger > #RAILS_DEFAULT_LOGGER > Logger.new(RAILS_ROOT + "/log/engines.log") > end>And then create an "engines.log" under your /log directory. Now all >engines related logging will be directed to that file instead of your >development.log.My question is, how to use it then? Wouldn''t it instantiate a new Logger instance every time I call it? def some_foo_method # I want to log something, I call the logger method logger.debug("I did something") end So, the "logger" method instantiates a new Logger instance every time. It is not good to have dozens logger instances in memory. How to avoid it? How to instantiate only once and then just use that one instance? -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7c8f4d12b04145da637e5998698b5791%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.