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.
45 46 47 48 |
# File 'lib/rails_semantic_logger/action_mailer/log_subscriber.rb', line 45 def initialize(event:, log_duration: false) @event = event @log_duration = log_duration end |
Instance Method Details
#date ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/rails_semantic_logger/action_mailer/log_subscriber.rb', line 72 def date if event.payload[:date].respond_to?(:to_time) event.payload[:date].to_time.utc elsif event.payload[:date].is_a?(String) Time.parse(date).utc end end |
#payload ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rails_semantic_logger/action_mailer/log_subscriber.rb', line 54 def payload {}.tap do |h| h[:event_name] = event.name h[:mailer] = mailer h[:action] = action h[:message_id] = event.payload[:message_id] h[:perform_deliveries] = event.payload[:perform_deliveries] h[:subject] = event.payload[:subject] h[:to] = event.payload[:to] h[:from] = event.payload[:from] h[:bcc] = event.payload[:bcc] h[:cc] = event.payload[:cc] h[:date] = date h[:duration] = event.duration.round(2) if log_duration? h[:args] = formatted_args end end |