How do I output a Rails logger in Delayed_Jobs?
I would like to lo开发者_StackOverflow中文版g @cf
in this delayed_job :
(CardReferral.all.map(&:email).map(&:downcase) - CardSignup.all.map(&:email).map(&:downcase)).each do |cf|
@cf = CardReferral.find_by_email(cf)
# <--- I want to add a Rails logger here
Notifier.deliver_referred_magic_email(User.find(@cf.user_id), @cf.email, @cf.name, @cf.message, subject, editor1)
end
Rails version in Rails 2.3.5 .
Any ideas?
The logger is accessible through the "logger" command in your models and controllers. You can call one of its methods to specify your message's log level (debug, info, warn, error, fatal), like this:
logger.debug("This will be logged")
You can find more in the Rails guides here.
It actually doesn't, add this in your task:
logger = Logger.new(STDOUT)
精彩评论