Sha256: c27227a15f290cb9209c2cb4a6ea2a6ee906b718a524e941faf30297fc98223a

Contents?: true

Size: 700 Bytes

Versions: 2

Compression:

Stored size: 700 Bytes

Contents

# frozen_string_literal: true

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

    def process_call_self(event)
      debug do
        interactor = event.payload[:interactor]
        "  Called #{interactor.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_interactor-2.3.1 lib/ii_interactor/log_subscriber.rb
ii_interactor-2.3.0 lib/ii_interactor/log_subscriber.rb