3

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?

awendt
  • 13,195
  • 5
  • 48
  • 66
  • possible duplicate of [Suppress Output in Rake Task db:schema:load](http://stackoverflow.com/questions/12079436/suppress-output-in-rake-task-dbschemaload) – Manuel Meurer Jun 01 '15 at 09:33
  • @ManuelMeurer I was going to say it's not but the answers would fit here. The initial problem statement sounded different. – awendt Jun 29 '15 at 07:41

1 Answers1

2

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
dexter
  • 13,365
  • 5
  • 39
  • 56