module MandrillQueue::Logging

Public Instance Methods

log_results(result) click to toggle source
# File lib/mandrill_queue/logging.rb, line 26
                def log_results(result)
                        errors = []
                        formatted = result.map do |r|
                                unless ['sent', 'queued'].include?(r['status'])
                                        errors << result_formatter(r)
                                end

                                result_formatter(r)
                        end

                        logger.debug <<-TXT.tr("\t", '')
                                \n*******************************************
                        #{formatted.join("\n")}
                                *******************************************
                        TXT

                        if errors.empty?
                                logger.info("#{result.count} message(s) successfully sent.")
                        else
                                logger.error("The following messages were not sent:\n#{errors.join("\n")}")
                        end
                end
logger() click to toggle source
# File lib/mandrill_queue/logging.rb, line 6
def logger
        MandrillQueue.configuration.logger
end
pretty(obj) click to toggle source
# File lib/mandrill_queue/logging.rb, line 10
def pretty(obj)
        s = StringIO.new
        PP.pp(obj, s)
        s.rewind
        s.read
end
result_formatter(r) click to toggle source
# File lib/mandrill_queue/logging.rb, line 17
                def result_formatter(r)
                        <<-TXT
                                ID: #{r['_id']}
                                EMAIL: #{r['email']}
                                STATUS: #{r['status']}
                                ---
                                TXT
                end