Module: LogStruct::Integrations::ActiveJob
- Extended by:
- IntegrationInterface, T::Sig
- Defined in:
- lib/log_struct/integrations/active_job.rb,
lib/log_struct/integrations/active_job/log_subscriber.rb
Overview
ActiveJob integration for structured logging
Defined Under Namespace
Classes: LogSubscriber
Class Method Summary collapse
-
.setup(config) ⇒ Boolean?
Set up ActiveJob structured logging.
Methods included from IntegrationInterface
Class Method Details
.setup(config) ⇒ Boolean?
Set up ActiveJob structured logging
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/log_struct/integrations/active_job.rb', line 22 def self.setup(config) return nil unless defined?(::ActiveJob::LogSubscriber) return nil unless config.enabled return nil unless config.integrations.enable_activejob ::ActiveSupport.on_load(:active_job) do if ::ActiveJob::LogSubscriber.respond_to?(:detach_from) # Detach the default text formatter ::ActiveJob::LogSubscriber.detach_from :active_job elsif ::ActiveSupport.respond_to?(:event_reporter) reporter = ::ActiveSupport.event_reporter reporter.unsubscribe(::ActiveJob::LogSubscriber) if reporter.respond_to?(:unsubscribe) end # Attach our structured formatter Integrations::ActiveJob::LogSubscriber.attach_to :active_job end true end |