Sha256: 5148d5e24dc84e2e8169ea515d1fd0aaa1e9801a438542d925f91731d6318bea
Contents?: true
Size: 837 Bytes
Versions: 2
Compression:
Stored size: 837 Bytes
Contents
module Sidekiq class JobLogger def call(item, queue) Sidekiq::Logging.with_context(log_context(item)) do begin start = Time.now logger.info("start".freeze) yield logger.info("done: #{elapsed(start)} sec") rescue Exception logger.info("fail: #{elapsed(start)} sec") raise end end end private # If we're using a wrapper class, like ActiveJob, use the "wrapped" # attribute to expose the underlying thing. def log_context(item) klass = item['wrapped'.freeze] || item["class".freeze] "#{klass} JID-#{item['jid'.freeze]}#{" BID-#{item['bid'.freeze]}" if item['bid'.freeze]}" end def elapsed(start) (Time.now - start).round(3) end def logger Sidekiq.logger end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-5.0.0.beta2 | lib/sidekiq/job_logger.rb |
sidekiq-5.0.0.beta1 | lib/sidekiq/job_logger.rb |