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
Overview
ActionMailer integration for structured logging
Defined Under Namespace
Modules: ErrorHandling, EventLogging, MetadataCollection
Class Method Summary collapse
-
.setup(config) ⇒ Boolean?
Set up ActionMailer structured logging.
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 45 46 47 48 49 50 51 52 53 54 |
# 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 # Silence default ActionMailer logs (we use our own structured logging) # This is required because we replace the logging using our own callbacks if defined?(::ActionMailer::Base) ::ActionMailer::Base.logger = ::Logger.new(File::NULL) end # Register our custom observers and handlers # Registering these at the class level means all mailers will use them ActiveSupport.on_load(:action_mailer) do prepend LogStruct::Integrations::ActionMailer::EventLogging prepend LogStruct::Integrations::ActionMailer::ErrorHandling prepend LogStruct::Integrations::ActionMailer::MetadataCollection end # If ActionMailer::Base is already loaded, the on_load hooks won't run # So we need to apply the modules directly if defined?(::ActionMailer::Base) ::ActionMailer::Base.prepend(LogStruct::Integrations::ActionMailer::EventLogging) ::ActionMailer::Base.prepend(LogStruct::Integrations::ActionMailer::ErrorHandling) ::ActionMailer::Base.prepend(LogStruct::Integrations::ActionMailer::MetadataCollection) end true end |