Module: ActiveSupport::OperationLogger

Defined in:
lib/active_support/operation_logger.rb,
lib/active_support/operation_logger/version.rb

Defined Under Namespace

Modules: EventInstrumenterFactory, EventSubscriberFactory, MethodHelper

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.log_calls_on!(klass, only: nil, event_namespace: nil) ⇒ Object

Encapsulates the act of decorating classes with ActiveSupport::Notifications instrumenters and ActiveSupport::LogSubscribers

TODO: @jbodah 2016-04-30: just use one shared event subscriber



78
79
80
81
82
83
84
85
86
# File 'lib/active_support/operation_logger.rb', line 78

def self.log_calls_on!(klass, only: nil, event_namespace: nil)
  methods = only || MethodHelper.public_owned_instance_methods(klass)
  event_namespace ||= klass.name.demodulize.underscore
  event_namespace = event_namespace.to_sym

  klass.prepend EventInstrumenterFactory.instrumenter_for(klass, methods, event_namespace)

  EventSubscriberFactory.subscriber_for(klass).attach_to(event_namespace)
end