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.2.0"

Class Method Summary collapse

Class Method Details

.log_calls_on!(klass, only: nil, event_namespace: nil, filter: 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



83
84
85
86
87
88
89
90
91
# File 'lib/active_support/operation_logger.rb', line 83

def self.log_calls_on!(klass, only: nil, event_namespace: nil, filter: 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, filter)

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