Class: Loga::Sidekiq6::JobLogger

Inherits:
Sidekiq::JobLogger
  • Object
show all
Defined in:
lib/loga/sidekiq6/job_logger.rb

Constant Summary collapse

EVENT_TYPE =
'sidekiq'.freeze

Instance Method Summary collapse

Instance Method Details

#call(item, _queue) ⇒ Object



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

def call(item, _queue)
  start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)

  yield

  with_elapsed_time_context(start) do
    loga_log(
      message: "#{item['class']} with jid: '#{item['jid']}' done", item: item,
    )
  end
rescue Exception => e # rubocop:disable Lint/RescueException
  with_elapsed_time_context(start) do
    loga_log(
      message: "#{item['class']} with jid: '#{item['jid']}' fail", item: item,
      exception: e
    )
  end

  raise
end