Sha256: a8805d63eff38199b38ea57a3585f6fcd5d0558978ac1e0db30beb3a8235e934

Contents?: true

Size: 1.08 KB

Versions: 16

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@zoolutions.se>
  #
  module Logging
    #
    # Context aware logging for Sidekiq Middlewares
    #
    # @author Mikael Henriksson <mikael@zoolutions.se>
    #
    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

16 entries across 16 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.0.0.beta25 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta24 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta23 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta22 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta21 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta20 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta19 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta18 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta17 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta16 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta15 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta14 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta13 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta12 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta11 lib/sidekiq_unique_jobs/logging/middleware_context.rb
sidekiq-unique-jobs-7.0.0.beta10 lib/sidekiq_unique_jobs/logging/middleware_context.rb