Sha256: b0610276deaf6bd50a2954040fb2baadf8452dac4a9870e22a5f99e3603d4183

Contents?: true

Size: 1.08 KB

Versions: 61

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  #
  # Provides the sidekiq middleware that makes the gem work
  #
  # @author Mikael Henriksson <mikael@mhenrixon.com>
  #
  module Logging
    #
    # Context aware logging for Sidekiq Middlewares
    #
    # @author Mikael Henriksson <mikael@mhenrixon.com>
    #
    module Middleware
      include Logging

      def self.included(base)
        base.class_eval do
          extend Logging::Middleware
        end
      end

      #
      # Provides a logging context for Sidekiq Middlewares
      #
      #
      # @return [Hash] when logger responds to `:with_context`
      # @return [String] when logger does not responds to `:with_context`
      #
      def logging_context
        middleware = is_a?(SidekiqUniqueJobs::Middleware::Client) ? :client : :server
        digest     = item[LOCK_DIGEST]
        lock_type  = item[LOCK]

        if logger_context_hash?
          { "uniquejobs" => middleware, lock_type => digest }
        else
          "uniquejobs-#{middleware} #{"DIG-#{digest}" if digest}"
        end
      end
    end
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-8.0.10 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.1.33 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.1.32 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.9 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.8 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.7 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.6 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.1.31 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.5 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.4 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.1.30 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.3 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.2 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.1 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-8.0.0 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.1.29 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.1.28 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.1.27 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.1.26 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.1.25 lib/sidekiq_unique_jobs/logging/middleware_context.rb