Class: Ezlog::Sidekiq::JobLogger

Inherits:
Object
  • Object
show all
Includes:
LogContextHelper
Defined in:
lib/ezlog/sidekiq/job_logger.rb

Instance Method Summary collapse

Methods included from LogContextHelper

#add_to_log_context, #within_log_context

Instance Method Details

#call(job_hash, _queue) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ezlog/sidekiq/job_logger.rb', line 8

def call(job_hash, _queue)
  within_log_context(JobContext.from_job_hash(job_hash)) do
    begin
      logger.info "#{job_hash['class']} started"
      benchmark { yield }
      logger.info message: "#{job_hash['class']} finished"
    rescue Exception
      logger.info message: "#{job_hash['class']} failed"
      raise
    end
  end
end

#with_job_hash_context(_job_hash, &_block) ⇒ Object Also known as: prepare



21
22
23
# File 'lib/ezlog/sidekiq/job_logger.rb', line 21

def with_job_hash_context(_job_hash, &_block)
  yield
end