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

Methods included from IntegrationInterface

setup

Class Method Details

.setup(config) ⇒ Boolean?

Set up ActiveJob structured logging

Parameters:

Returns:

  • (Boolean, nil)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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
    # Detach the default text formatter
    ::ActiveJob::LogSubscriber.detach_from :active_job

    # Attach our structured formatter
    Integrations::ActiveJob::LogSubscriber.attach_to :active_job
  end
  true
end