Class: RailsSemanticLogger::ActionMailer::LogSubscriber::EventFormatter
- Inherits:
-
Object
- Object
- RailsSemanticLogger::ActionMailer::LogSubscriber::EventFormatter
- Defined in:
- lib/rails_semantic_logger/action_mailer/log_subscriber.rb
Instance Method Summary collapse
- #date ⇒ Object
-
#initialize(event:, log_duration: false) ⇒ EventFormatter
constructor
A new instance of EventFormatter.
- #payload ⇒ Object
Constructor Details
#initialize(event:, log_duration: false) ⇒ EventFormatter
Returns a new instance of EventFormatter.
62 63 64 65 |
# File 'lib/rails_semantic_logger/action_mailer/log_subscriber.rb', line 62 def initialize(event:, log_duration: false) @event = event @log_duration = log_duration end |
Instance Method Details
#date ⇒ Object
89 90 91 |
# File 'lib/rails_semantic_logger/action_mailer/log_subscriber.rb', line 89 def date event.payload[:date].to_time.utc if event.payload[:date].respond_to?(:to_time) end |
#payload ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rails_semantic_logger/action_mailer/log_subscriber.rb', line 67 def payload p = event.payload {}.tap do |h| h[:event_name] = event.name h[:mailer] = mailer h[:action] = action h[:message_id] = p[:message_id] h[:perform_deliveries] = p[:perform_deliveries] h[:subject] = p[:subject] h[:to] = p[:to] h[:from] = p[:from] h[:bcc] = p[:bcc] h[:cc] = p[:cc] h[:date] = date # Rails dumps the full encoded message at debug level via `debug { event.payload[:mail] }`. # The `deliver` event is debug-gated, so include it here whenever it is present. h[:mail] = p[:mail] if p[:mail] h[:duration] = event.duration.round(2) if log_duration? h[:args] = formatted_args end end |