Module: LogStruct::Integrations::ActionMailer
- Extended by:
- IntegrationInterface, T::Sig
- Defined in:
- lib/log_struct/integrations/action_mailer.rb,
lib/log_struct/integrations/action_mailer/event_logging.rb,
lib/log_struct/integrations/action_mailer/error_handling.rb,
lib/log_struct/integrations/action_mailer/metadata_collection.rb,
lib/log_struct/integrations/action_mailer/fallback_error_handlers.rb
Overview
ActionMailer integration for structured logging
Defined Under Namespace
Modules: ErrorHandling, EventLogging, FallbackErrorHandlers, MetadataCollection
Class Method Summary collapse
-
.setup(config) ⇒ Boolean?
Set up ActionMailer structured logging.
-
.setup_fallback_error_handlers(config) ⇒ void
Where LogStruct doesn't set up ActionMailer, mailers still get the error handlers they can name in rescue_from (see FallbackErrorHandlers).
Methods included from IntegrationInterface
Class Method Details
.setup(config) ⇒ Boolean?
Set up ActionMailer structured logging
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/log_struct/integrations/action_mailer.rb', line 26 def self.setup(config) return nil unless defined?(::ActionMailer) return nil unless config.enabled return nil unless config.integrations.enable_actionmailer # Register our custom observers and handlers on all mailers. The hook runs right away # if ActionMailer::Base is already loaded. ActiveSupport.on_load(:action_mailer) do # LogStruct's delivery lines replace Rails' mail lines, which also log the whole mail at debug level. # Mailers keep their logger, so an app's own logger calls in a mailer are still logged. RailsLogSubscribers.detach(::ActionMailer::LogSubscriber, :action_mailer) if defined?(::ActionMailer::LogSubscriber) prepend LogStruct::Integrations::ActionMailer::EventLogging prepend LogStruct::Integrations::ActionMailer::ErrorHandling prepend LogStruct::Integrations::ActionMailer::MetadataCollection end true end |
.setup_fallback_error_handlers(config) ⇒ void
This method returns an undefined value.
Where LogStruct doesn't set up ActionMailer, mailers still get the error handlers they can name in rescue_from (see FallbackErrorHandlers)
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/log_struct/integrations/action_mailer.rb', line 49 def self.setup_fallback_error_handlers(config) return unless defined?(::ActionMailer) return if config.enabled && config.integrations.enable_actionmailer ActiveSupport.on_load(:action_mailer) do next if include?(LogStruct::Integrations::ActionMailer::FallbackErrorHandlers) include LogStruct::Integrations::ActionMailer::FallbackErrorHandlers extend LogStruct::Integrations::ActionMailer::FallbackErrorHandlers::ClassMethods end end |