Class: Sidekiq::SemanticLogging

Inherits:
JobLogger
  • Object
show all
Defined in:
lib/sidekiq/semantic_logging.rb

Instance Method Summary collapse

Constructor Details

#initializeSemanticLogging

Returns a new instance of SemanticLogging.



7
8
9
10
# File 'lib/sidekiq/semantic_logging.rb', line 7

def initialize
  logger = Rails.logger
  super(logger)
end

Instance Method Details

#call(_worker, item, queue) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sidekiq/semantic_logging.rb', line 12

def call(_worker, item, queue)
  logger_tags = {
    class: item['class'],
    jid: item['jid'],
    request_id: item['request_id'],
    remote_ip: item['remote_ip'],
    user_agent: item['user_agent'],
    user_uuid: item['user_uuid'] || 'N/A',
    source: item['source']
  }
  Thread.current[:sidekiq_context] = {}

  @logger.tagged(**logger_tags) do
    super(item, queue)
  end
end