Class: DBI::HandleTracer
- Inherits:
-
AspectR::Aspect
- Object
- AspectR::Aspect
- DBI::HandleTracer
- Defined in:
- lib/dbi/trace.rb
Instance Method Summary collapse
-
#initialize(klass) ⇒ HandleTracer
constructor
A new instance of HandleTracer.
- #post(method, object, exitstatus, *args) ⇒ Object
-
#pre(method, object, exitstatus, *args) ⇒ Object
trace methods ————————————————————–.
Constructor Details
#initialize(klass) ⇒ HandleTracer
Returns a new instance of HandleTracer.
31 32 33 34 |
# File 'lib/dbi/trace.rb', line 31 def initialize(klass) @never_wrap = /^__|^send$|^id$|^class$|^$ / self.wrap(klass, :pre, :post, methods(klass)) end |
Instance Method Details
#post(method, object, exitstatus, *args) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dbi/trace.rb', line 49 def post(method, object, exitstatus, *args) case object.trace_mode when 1, 2 # return values and errors arrow = object.trace_mode == 1 ? "<=" : "<-" if exitstatus.kind_of? Array object.trace_output << "#{arrow} #{method} for #{object} = #{exitstatus[0] || 'nil'}\n" else if exitstatus == true object.trace_output << "!! #{$!..chomp}\n" end object.trace_output << "#{arrow} #{method} for #{object}\n" end when 3 if exitstatus.kind_of? Array object.trace_output << "<- #{method} for #{object.inspect} = #{exitstatus[0].inspect}\n" else if exitstatus == true object.trace_output << "!! #{$!.inspect}\n" end object.trace_output << "<- #{method} for #{object.inspect}\n" end end end |
#pre(method, object, exitstatus, *args) ⇒ Object
trace methods ————————————————————–
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dbi/trace.rb', line 38 def pre(method, object, exitstatus, *args) par = args.collect{|a| a.inspect}.join(", ") if object.trace_mode == 2 then object.trace_output << "-> #{method} for #{object} (#{par})\n" elsif object.trace_mode == 3 then object.trace_output << "-> #{method} for #{object.inspect} (#{par})\n" end end |