Disable Globalize::ViewTranslation SQL logging
posted: September 16th, 2007 · by: Sven
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?