class DebugLogging::Configuration

Attributes

methods_to_log[R]

Public Class Methods

config_pointer(type, method_to_log) click to toggle source
# File lib/debug_logging/configuration.rb, line 35
def config_pointer(type, method_to_log)
  # Methods names that do not match the following regex can't be part of an ivar name
  #   /[a-zA-Z_][a-zA-Z0-9_]*/
  # Thus we have to use a different form of the method name that is compatible with ivar name conventions
  "@debug_logging_config_#{type}_#{Digest::MD5.hexdigest(method_to_log.to_s)}".to_sym
end
new(**options) click to toggle source
# File lib/debug_logging/configuration.rb, line 42
def initialize(**options)
  CONFIG_ATTRS.each do |key|
    send("#{key}=", get_attr_from_options(options, key))
  end
  CONFIG_READERS.each do |key|
    send("#{key}=", get_reader_from_options(options, key))
  end
  @methods_to_log = []
end

Public Instance Methods

active_support_notifications=(active_support_notifications) click to toggle source
# File lib/debug_logging/configuration.rb, line 91
def active_support_notifications=(active_support_notifications)
  require 'debug_logging/active_support_notifications' if active_support_notifications
  @active_support_notifications = active_support_notifications
end
benchmarkable_for?(benchmarks) click to toggle source
# File lib/debug_logging/configuration.rb, line 69
def benchmarkable_for?(benchmarks)
  return @benchmarkable if defined?(@benchmarkable)

  @benchmarkable = loggable? && send(benchmarks)
end
class_benchmarks=(class_benchmarks) click to toggle source
# File lib/debug_logging/configuration.rb, line 86
def class_benchmarks=(class_benchmarks)
  require 'benchmark' if class_benchmarks
  @class_benchmarks = class_benchmarks
end
exit_scope_markable?() click to toggle source
# File lib/debug_logging/configuration.rb, line 75
def exit_scope_markable?
  return @exit_scope_markable if defined?(@exit_scope_markable)

  @exit_scope_markable = loggable? && mark_scope_exit
end
instance_benchmarks=(instance_benchmarks) click to toggle source
# File lib/debug_logging/configuration.rb, line 81
def instance_benchmarks=(instance_benchmarks)
  require 'benchmark' if instance_benchmarks
  @instance_benchmarks = instance_benchmarks
end
log(message = nil, &block) click to toggle source
# File lib/debug_logging/configuration.rb, line 52
def log(message = nil, &block)
  return unless enabled
  return unless logger

  if block
    logger.send(log_level, &block)
  else
    logger.send(log_level, message)
  end
end
loggable?() click to toggle source
# File lib/debug_logging/configuration.rb, line 63
def loggable?
  return @loggable if defined?(@loggable)

  @loggable = logger.send("#{log_level}?")
end
register(method_lo_log) click to toggle source
# File lib/debug_logging/configuration.rb, line 102
def register(method_lo_log)
  @methods_to_log << method_lo_log
end
to_hash() click to toggle source
# File lib/debug_logging/configuration.rb, line 96
def to_hash
  CONFIG_KEYS.each_with_object({}) do |key, hash|
    hash[key] = instance_variable_get("@#{key}")
  end
end

Private Instance Methods

get_attr_from_options(options, key) click to toggle source
# File lib/debug_logging/configuration.rb, line 108
def get_attr_from_options(options, key)
  options.key?(key) ? options[key] : CONFIG_ATTRS_DEFAULTS[key]
end
get_reader_from_options(options, key) click to toggle source
# File lib/debug_logging/configuration.rb, line 112
def get_reader_from_options(options, key)
  options.key?(key) ? options[key] : CONFIG_READERS_DEFAULTS[key]
end