Module: Moto::RunnerLogging

Defined in:
lib/runner_logging.rb

Class Method Summary collapse

Class Method Details

.included(cls) ⇒ Object

TODO: merge it somehow with TestLogging. Parametrize logger object?



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/runner_logging.rb', line 6

def self.included(cls)
  def cls.method_added(name)
    excluded_methods = Moto::EmptyListener.instance_methods(false)
    excluded_methods << :new
    excluded_methods << :initialize
    # TODO: configure more excluded classes/methods
    return if @added 
    @added = true # protect from recursion
    original_method = "original_#{name}"
    alias_method original_method, name
    define_method(name) do |*args|
      @context.runner.logger.debug("#{self.class.name}::#{__callee__} ENTER >>> #{args}") unless excluded_methods.include? name 
      result = send original_method, *args
      @context.runner.logger.debug("#{self.class.name}::#{__callee__} LEAVE <<< #{result} ") unless excluded_methods.include? name
      result
    end
    @added = false
  end

end