Class: Sidecloq::Utils::ContextLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/sidecloq/utils.rb

Overview

Sets the Sidekiq::Logging context automatically with direct calls to *.logger

Instance Method Summary collapse

Constructor Details

#initialize(ctx) ⇒ ContextLogger

Returns a new instance of ContextLogger.



7
8
9
# File 'lib/sidecloq/utils.rb', line 7

def initialize(ctx)
  @context = ctx
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



11
12
13
14
15
# File 'lib/sidecloq/utils.rb', line 11

def method_missing(meth, *args)
  Sidekiq::Logging.with_context(@context) do
    Sidekiq.logger.send(meth, args)
  end
end