logger.silence do
# your code here
end
http://wiki.rubyonrails.org/rails/pages/HowtoSelectivelySuppressLogging
On Nov 16, 2007, at 7:14 AM, Emmanuel Oga wrote:
>
> Hi! I want to do what subject say. Is there any elegant way to do
> this:
> ???
>
> # Silence the log inside the block attached to the method call.
> def silence_logger
> orig= nil
>
> ObjectSpace.each_object(::Logger) do |logger|
> logger.info "-" * 80
> logger.info "Quieting the log..."
> orig= logger.level
> logger.level= ::Logger::FATAL
> end
>
> yield
>
> ObjectSpace.each_object(::Logger) do |logger|
> logger.level= orig
> logger.info "Log is alive again!"
> logger.info "-" * 80
> end
> end
>
> silence_logger do
> something
> end
>
> Thanks!!!
> --
> 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
-~----------~----~----~----~------~----~------~--~---