In Rails 3.2 I get deprecation warning, when using logger.silence {}. In release note: "ActiveSupport::BufferedLogger#silence is deprecated. If you want to squelch logs for a certain block, change the log level for that block."
How I can easily change log level for the block?
It appears that logger.silence
is being replaced by simply silence
:
logger.silence do
#your silenced code here
end
becomes:
silence do
#your silenced code here
end
At least it doesn't generate the depreciation warning anymore, and it does silence the logged output.
The first answer is good, but not complete. We were having issues trying to figure this one out too. silence &block
has been deprecated in Rails 3, so you should use the updated syntax calling the logger directly:
Rails.logger.silence do
# your code here...
end
For even more sweet, sweet customizability, you can pass a log level to #silence().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With