Class: Webdrone::MethodLogger
- Inherits:
-
Module
- Object
- Module
- Webdrone::MethodLogger
- Defined in:
- lib/webdrone/logg.rb
Instance Method Summary collapse
- #included(base) ⇒ Object
-
#initialize(methods_0 = nil) ⇒ MethodLogger
constructor
A new instance of MethodLogger.
Constructor Details
#initialize(methods_0 = nil) ⇒ MethodLogger
Returns a new instance of MethodLogger.
3 4 5 |
# File 'lib/webdrone/logg.rb', line 3 def initialize(methods_0 = nil) @methods_0 = methods_0 end |
Instance Method Details
#included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/webdrone/logg.rb', line 7 def included(base) @methods_0 = base.instance_methods(false) if @methods_0 == nil method_list = @methods_0 base.class_eval do method_list.each do |method_name| original_method = instance_method(method_name) define_method method_name do |*args, &block| caller_location = Kernel.caller_locations[0] cl_path = caller_location.path cl_line = caller_location.lineno if @a0.conf.logger and Gem.path.none? { |path| cl_path.include? path } $a0_webdrone_logger_last_time = Time.new unless $a0_webdrone_logger_last_time ini = $a0_webdrone_logger_last_time $a0_webdrone_screenshot = nil begin result = original_method.bind(self).call(*args, &block) fin = $a0_webdrone_logger_last_time = Time.new @a0.logs.trace(ini, fin, cl_path, cl_line, base, method_name, args, result, nil, $a0_webdrone_screenshot) result rescue => exception fin = $a0_webdrone_logger_last_time = Time.new @a0.logs.trace(ini, fin, cl_path, cl_line, base, method_name, args, nil, exception, $a0_webdrone_screenshot) raise exception end else original_method.bind(self).call(*args, &block) end end end end end |