Module: MandrillQueue::Logging

Included in:
Hooks, Worker
Defined in:
lib/mandrill_queue/logging.rb

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 "    \\n*******************************************\n  \#{formatted.join(\"\\n\")}\n    *******************************************\n  TXT\n\n  if errors.empty?\n    logger.info(\"\#{result.count} message(s) successfully sent.\")\n  else\n    logger.error(\"The following messages were not sent:\\n\#{errors.join(\"\\n\")}\")\n  end\nend\n".tr("\t", '')

#loggerObject



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)
  "    ID: \#{r['_id']}\n    EMAIL: \#{r['email']}\n    STATUS: \#{r['status']}\n    ---\n    TXT\nend\n"