Class: IndentedTracer

Inherits:
Tracer
  • Object
show all
Defined in:
lib/indented-tracer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIndentedTracer

Returns a new instance of IndentedTracer.



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
38
39
40
# File 'lib/indented-tracer.rb', line 11

def initialize()
  super

  add_filter do |event, file, line, id, binding, klass, *rest|

    if @classes.map(&:to_s).include? klass.to_s then

      if event == 'call' then

        if @a.nil? then
          @a = []
          @current = @a

        end
 
        @current << [klass.to_s + '#' + id.to_s]            
        @grandparent = @parent
        @parent = @current
        @current = @current.last

      elsif event == 'return'

        @current = @parent
        @parent = @grandparent
      end 
      
    end
  end

end

Instance Attribute Details

#classesObject

Returns the value of attribute classes.



9
10
11
# File 'lib/indented-tracer.rb', line 9

def classes
  @classes
end

Instance Method Details

#log(title, tags: tags=[]) ⇒ Object



42
43
44
45
46
# File 'lib/indented-tracer.rb', line 42

def log(title, tags: tags=[])
  "<?polyrex schema='session[title,tags]/entry[classname, methodname]' " + \
      "delimiter='#'?>\ntitle: #{title}\ntags: #{(['trace'] + tags)
      .join(' ')}\n\n" +  print_all(@a)
end