class IndentedTracer
Attributes
classes[RW]
ignore_methods[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/indented-tracer.rb, line 11 def initialize() super @ignore_methods = [] add_filter do |event, file, line, id, binding, klass, *rest| if @classes.map(&:to_s).include? klass.to_s and !@ignore_methods.map(&:to_sym).include? id.to_sym 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
Public Instance Methods
log(title='', tags: tags=[])
click to toggle source
# File lib/indented-tracer.rb, line 45 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
Private Instance Methods
print_all(a, buffer='', indent=0)
click to toggle source
# File lib/indented-tracer.rb, line 53 def print_all(a, buffer='', indent=0) lines = a.map do |x| r = (' ' * indent) + x.first.to_s x.length > 1 ? r + "\n" + print_all(x[1..-1], buffer, indent+1) : r end lines.join("\n") end