Module: Tengine::Core::MethodTraceable

Included in:
Bootstrap, HeartbeatWatcher, Kernel, Plugins, Scheduler
Defined in:
lib/tengine/core/method_traceable.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.disabledObject

Returns the value of attribute disabled.



6
7
8
# File 'lib/tengine/core/method_traceable.rb', line 6

def disabled
  @disabled
end

Instance Method Details

#method_trace(*symbols) ⇒ Object



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
# File 'lib/tengine/core/method_traceable.rb', line 9

def method_trace(*symbols)
  symbols.each do |symbol|
    original_method = :"_unmethod_traceable_#{symbol}"
    class_eval("      if method_defined?(:\#{original_method})                                  # if method_defined?(:_unmemoized_mime_type)\n        raise \"Already method_tracing \#{symbol}\"                               #   raise \"Already memoized mime_type\"\n      end                                                                      # end\n      alias \#{original_method} \#{symbol}                                       # alias _unmemoized_mime_type mime_type\n\n      def \#{symbol}(*args, &block)\n        disabled = Tengine::Core::MethodTraceable.disabled\n        begin\n          Tengine::Core::stdout_logger.info(\"\\\#{self.class.name}#\#{symbol} called\") unless disabled\n          result = \#{original_method}(*args, &block)\n          Tengine::Core::stdout_logger.info(\"\\\#{self.class.name}#\#{symbol} complete\") unless disabled\n          return result\n        rescue Exception => e\n          unless e.instance_variable_get(:@__traced__) || disabled\n            Tengine::Core::stderr_logger.error(\"\\\#{self.class.name}#\#{symbol} failure. [\\\#{e.class.name}] \\\#{e.message}\\n  \" << e.backtrace.join(\"\\n  \"))\n            e.instance_variable_set(:@__traced__, true)\n          end\n          raise\n        end\n      end\n\n    EOS\n  end\nend\n", __FILE__, __LINE__ +1)