Sha256: 6e26bfbfadac0d9557555130db8329397b6ed898cac7927f9153e740298a3dfc

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 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.0 lib/ii_finder/log_subscriber.rb
ii_finder-2.1.0 lib/ii_finder/log_subscriber.rb