Sha256: 63d6011e915e319452711c10153fa6ea904fb81740c53cb84a23b0c2ab0e0f9c

Contents?: true

Size: 648 Bytes

Versions: 2

Compression:

Stored size: 648 Bytes

Contents

# frozen_string_literal: true

module IIFinder
  class LogSubscriber < ActiveSupport::LogSubscriber
    def calling(event)
      debug do
        finder = event.payload[:finder]
        "  Calling #{finder.class} with #{finder.context}"
      end
    end

    def call(event)
      debug do
        finder = event.payload[:finder]
        "  Called #{finder.class} (#{additional_log(event)})"
      end
    end

    private

    def additional_log(event)
      additions = ["Duration: %.1fms" % event.duration]
      additions << "Allocations: %d" % event.allocations if event.respond_to?(:allocations)
      additions.join(', ')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ii_finder-2.2.2 lib/ii_finder/log_subscriber.rb
ii_finder-2.2.1 lib/ii_finder/log_subscriber.rb