Sha256: 30788433096a6ab9c199bea357c6f3b9dc04ee0936a0d6bed53f36b527e214d7

Contents?: true

Size: 439 Bytes

Versions: 3

Compression:

Stored size: 439 Bytes

Contents

module Sidekiq
  class JobLogger

    def call(item, queue)
      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

    private

    def elapsed(start)
      (Time.now - start).round(3)
    end

    def logger
      Sidekiq.logger
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq-5.0.0 lib/sidekiq/job_logger.rb
sidekiq-5.0.0.rc1 lib/sidekiq/job_logger.rb
sidekiq-5.0.0.beta3 lib/sidekiq/job_logger.rb