Class: Logged::LogSubscriber::ActionMailer

Inherits:
Base
  • Object
show all
Defined in:
lib/logged/log_subscriber/action_mailer.rb

Overview

Log subscriber for ActionMailer events

Instance Method Summary collapse

Methods inherited from Base

component, #logger

Instance Method Details

#deliver(event) ⇒ Object

An email was delivered.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/logged/log_subscriber/action_mailer.rb', line 10

def deliver(event)
  return if ignore?(event, :debug)

  process_duration = Thread.current[:logged_action_mailer_process_duration] || 0.0

  data = {
    event:    event.name,
    duration: (process_duration + event.duration.to_f).round(2)
  }

  data.merge!(extract_mail_deliver(event.payload))

  Thread.current[:logged_action_mailer_process_duration] = nil

  debug(event, data)
end

#process(event) ⇒ Object

An email was generated.



41
42
43
44
45
46
47
# File 'lib/logged/log_subscriber/action_mailer.rb', line 41

def process(event)
  payload = event.payload

  Thread.current[:logged_action_mailer_process_mailer]   = payload[:mailer]
  Thread.current[:logged_action_mailer_process_action]   = payload[:action]
  Thread.current[:logged_action_mailer_process_duration] = event.duration.to_f
end

#receive(event) ⇒ Object

An email was received.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/logged/log_subscriber/action_mailer.rb', line 28

def receive(event)
  return unless logger.debug?
  return if ignore?(event)

  data = {
    event:    event.name,
    duration: event.duration.to_f.round(2)
  }

  debug(event, data)
end