I have a Rake task that depends on Rake::PackageTask. I need the output from my own task in our logs but I don't need 1000+ lines of output from the package task.
Is there any way I can silence Rake::PackageTask? Or is there a way I can programmatically silence any task, without having to specify rake --silent?
You can redirect logs to /dev/null before calling the silent rake task. And then restore them back..
dev_null = Logger.new("/dev/null")
Rails.logger = dev_null
ActiveRecord::Base.logger = dev_null
Rake::Task['blah_blak'].invoke
#then restore the logger back
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