Module: Rubylog::Tracing

Included in:
Rubylog
Defined in:
lib/rubylog/tracing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#trace_levelsObject

Returns the value of attribute trace_levels.



10
11
12
# File 'lib/rubylog/tracing.rb', line 10

def trace_levels
  @trace_levels
end

#traceable_methodsObject (readonly)

Returns the value of attribute traceable_methods.



9
10
11
# File 'lib/rubylog/tracing.rb', line 9

def traceable_methods
  @traceable_methods
end

Instance Method Details

#trace(value = true) ⇒ Object

Turns trace on. If value is given and is false, turns trace off. If a block is given, calls the block with trace on.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubylog/tracing.rb', line 15

def trace value=true
  if not block_given?
    @trace = value
    @trace_levels = 0
    update_trace
  else
    begin
      trace
      return yield
    ensure
      trace false
    end
  end
end

#trace?Boolean

returns true if tracing is active

Returns:

  • (Boolean)


31
32
33
# File 'lib/rubylog/tracing.rb', line 31

def trace?
  @trace
end

#traceable(method) ⇒ Object



36
37
38
39
# File 'lib/rubylog/tracing.rb', line 36

def traceable method
  @traceable_methods ||= []
  @traceable_methods << method
end