Antarr Byrd
Antarr Byrd

Reputation: 26091

Logging to rails console with rake

I have a rake file that is being called by a job scheduler. The file outputs the desc but I am not able to log anything else to the console. What am I missing?

inbox.rake

namespace :inbox do
  desc 'Check inbox for new app builds'
  task process_inbox: :environment do
    puts "my task is working"  
  end
end

Upvotes: 3

Views: 3904

Answers (4)

yujingz
yujingz

Reputation: 2389

Similar to Heroku logs, you need STDOUT to see the outputs. Could be as simple as

my_logger = Logger.new(STDOUT)
my_logger.info "work or die"

Upvotes: 3

Mario Carrion
Mario Carrion

Reputation: 672

You're not using --quiet / --silent are you?

Upvotes: 1

Ben Scheirman
Ben Scheirman

Reputation: 40961

puts sends the text to STDOUT, which is different when you run rake from the terminal versus invoking from another ruby process.

Where do you expect to see this text?

Upvotes: 1

miler350
miler350

Reputation: 1421

Try manually printing to console.

namespace :inbox do
  desc 'Check inbox for new app builds'
  task process_inbox: :environment do
    Rails.logger.info "my task is working"  
  end
end

Upvotes: 1

Related Questions