Skip to Content Skip to Search
Methods
C
D
E
L
S

Constants

LOG_LEVELS = [:debug, :info, :warn, :error].freeze
 

Attributes

[W] logger
[RW] namespace

Class Public methods

default_logger()

# File activesupport/lib/active_support/event_reporter/log_subscriber.rb, line 39
def default_logger
  raise NotImplementedError
end

event_log_level(method_name, level)

# File activesupport/lib/active_support/event_reporter/log_subscriber.rb, line 31
def event_log_level(method_name, level)
  self.log_levels = log_levels.merge(method_name.to_s => level).freeze
end

logger()

# File activesupport/lib/active_support/event_reporter/log_subscriber.rb, line 35
def logger
  @logger || default_logger
end

subscription_filter()

# File activesupport/lib/active_support/event_reporter/log_subscriber.rb, line 46
def subscription_filter
  prefix = "#{namespace}.".freeze
  proc do |event|
    event[:name].start_with?(prefix)
  end
end

Instance Public methods

consumes?(name)

Whether an event with this name would currently be logged, so that the event reporter can skip building events this subscriber would discard. Deliberately not memoized: the answer changes with the logger’s level.

# File activesupport/lib/active_support/event_reporter/log_subscriber.rb, line 67
def consumes?(name)
  return false unless logger

  log_level_satisfied?(self.class.event_method_for(name))
end

emit(event)

# File activesupport/lib/active_support/event_reporter/log_subscriber.rb, line 56
def emit(event)
  return unless logger
  event_method = self.class.event_method_for(event[:name])

  public_send(event_method, event) if log_level_satisfied?(event_method)
end

logger()

# File activesupport/lib/active_support/event_reporter/log_subscriber.rb, line 73
def logger
  self.class.logger
end