Class: Loga::LogSubscribers::ActionMailer
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Loga::LogSubscribers::ActionMailer
- Defined in:
- lib/loga/log_subscribers/action_mailer.rb
Overview
Loga::LogSubscribers::ActionMailer tracks the three mailing events: ‘process’, ‘deliver’ and ‘receive’, and builds a loga event instance for each particular invocation.
Instance Method Summary collapse
- #deliver(event) ⇒ Object
- #hide_pii? ⇒ Boolean
- #logger ⇒ Object
- #process(event) ⇒ Object
- #receive(event) ⇒ Object
Instance Method Details
#deliver(event) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/loga/log_subscribers/action_mailer.rb', line 7 def deliver(event) mailer = event.payload[:mailer] recipients = event.payload[:to].join(',') unique_id = event.payload[:unique_id] duration = event.duration.round(1) = ''.tap do |string| string << "#{mailer}: Sent mail" string << " to #{recipients}" unless hide_pii? string << " in (#{duration}ms)" end loga_event = Event.new( data: { mailer: mailer, unique_id: unique_id }, message: , type: 'action_mailer', ) logger.info(loga_event) end |
#hide_pii? ⇒ Boolean
67 68 69 |
# File 'lib/loga/log_subscribers/action_mailer.rb', line 67 def hide_pii? Loga.configuration.hide_pii end |
#logger ⇒ Object
63 64 65 |
# File 'lib/loga/log_subscribers/action_mailer.rb', line 63 def logger Loga.logger end |
#process(event) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/loga/log_subscribers/action_mailer.rb', line 27 def process(event) mailer = event.payload[:mailer] action = event.payload[:action] unique_id = event.payload[:unique_id] duration = event.duration.round(1) = "#{mailer}##{action}: Processed outbound mail in (#{duration}ms)" loga_event = Event.new( data: { mailer: mailer, unique_id: unique_id, action: action }, message: , type: 'action_mailer', ) logger.debug(loga_event) end |
#receive(event) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/loga/log_subscribers/action_mailer.rb', line 44 def receive(event) from = event.payload[:from] mailer = event.payload[:mailer] unique_id = event.payload[:unique_id] = ''.tap do |string| string << 'Received mail' string << " from #{from}" unless hide_pii? string << " in (#{event.duration.round(1)}ms)" end loga_event = Event.new( data: { mailer: mailer, unique_id: unique_id }, message: , type: 'action_mailer', ) logger.info(loga_event) end |