Sha256: fd09bf3d08d0b4b143092355097745aaa9a81d8710274e0490361f743f07fafb

Contents?: true

Size: 687 Bytes

Versions: 4

Compression:

Stored size: 687 Bytes

Contents

module Sidekiq
  module Middleware
    module Server
      class Logging

        def call(*args)
          Sidekiq::Logging.with_context("#{args[0].class.to_s} MSG-#{args[0].object_id.to_s(36)}") do
            begin
              start = Time.now
              logger.info { "start" }
              yield
              logger.info { "done: #{elapsed(start)} sec" }
            rescue Exception
              logger.info { "fail: #{elapsed(start)} sec" }
              raise
            end
          end
        end

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

        def logger
          Sidekiq.logger
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sidekiq-2.3.3 lib/sidekiq/middleware/server/logging.rb
sidekiq-2.3.2 lib/sidekiq/middleware/server/logging.rb
sidekiq-2.3.1 lib/sidekiq/middleware/server/logging.rb
sidekiq-2.3.0 lib/sidekiq/middleware/server/logging.rb