awendt
awendt

Reputation: 13673

Can I programmatically silence Rake tasks?

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?

Upvotes: 3

Views: 1618

Answers (1)

dexter
dexter

Reputation: 13583

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

Upvotes: 2

Related Questions