Module: MandrillQueue::Logging
Instance Method Summary collapse
Instance Method Details
#log_results(result) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 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 ⇒ Object
6 7 8 |
# File 'lib/mandrill_queue/logging.rb', line 6 def logger MandrillQueue.configuration.logger end |
#pretty(obj) ⇒ Object
10 11 12 13 14 15 |
# 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) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/mandrill_queue/logging.rb', line 17 def result_formatter(r) <<-TXT ID: #{r['_id']} EMAIL: #{r['email']} STATUS: #{r['status']} --- TXT end |