Class: Loggun::Modifiers::Sidekiq

Inherits:
Base
  • Object
show all
Defined in:
lib/loggun/modifiers/sidekiq.rb,
lib/loggun/modifiers/sidekiq/sidekiq4.rb,
lib/loggun/modifiers/sidekiq/sidekiq6.rb

Defined Under Namespace

Classes: ClientMiddleware, LoggunFormatter

Constant Summary collapse

MIN_SIDEKIQ_V =
'4.0.0'.freeze

Instance Method Summary collapse

Methods inherited from Base

#config, use

Instance Method Details

#applyObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/loggun/modifiers/sidekiq.rb', line 8

def apply
  return unless defined?(::Sidekiq) && ::Sidekiq::VERSION >= MIN_SIDEKIQ_V

  if ::Sidekiq::VERSION >= '7.0.0'
    ::Sidekiq.configure_client do |config|
      config.client_middleware do |chain|
        chain.add ClientMiddleware
      end
    end
  else
    ::Sidekiq.client_middleware do |chain|
      chain.add ClientMiddleware
    end
  end

  ::Sidekiq.configure_server do |config|
    Loggun::Config.setup_formatter(config, LoggunFormatter.new)
  end
end