Disable Globalize::ViewTranslation SQL logging

posted: September 16th, 2007 · by: Sven

in: Globalization, Programming · tagged as: , , , , , , , ·  0 comments »

Sometimes you just want less noise in your log files, especially when your Globalize setup runs pretty fine and you don’t need it to tell you about every single move it makes: Globalize can be just too chatty then.

Joost Hietbrink thought this, too, and sent me the following code snippet. So you don’t need to suffer from Globalize’s chattiness any more :-)

module Globalize # :nodoc:
 class DbViewTranslator
   alias_method :orig_fetch_view_translation, :fetch_view_translation
   def fetch_view_translation(key, language, idx, namespace = nil)
     ActiveRecord::Base.silence do
       orig_fetch_view_translation(key, language, idx, namespace = nil)
     end
   end
 end
end

Obviously, this wraps around the Globalize’s fetch_view_translation method and uses ActiveRecord::Base#silence to prevent ActiveRecord from logging the query.

That’s handy. I’ve added this to the Tips & tricks installment of the Globalize series.

Thanks, Joost!

PS: … wow, let me guess, is there a Globalize installation using subdomains for locales peeking from behind the curtains of YellowYellow?

Leave a comment

Name required
E-Mail and Website optional

If you can read this, you don't use a typical webbrowser that plays nice with CSS.
Please do not fill in anything here!

Hint: You're going to comment a Globalize-related article. If you are going to post a bugreport or ask a usage-related question you might want to consider subscribing to the Globalize users mailinglist instead and post over there. In any case, your comment is appreciated and welcome here, too :-)

Hint: Markdown will be applied to your comment. If you post any code, be sure to escape underscores (like so: \_) if you do not want them to be converted to an <em>phasis.

artweb design
Sven Fuchs
Grünberger Str. 65
10245 Berlin, Germany


http://www.artweb-design.de

Fon +49 (30) 47 98 69 96
Fax +49 (30) 47 98 69 97