class Tracing < Team
  class Trace

    #stack depth (static)
    @@depth=0
    
    # enter method
    def enter()
      print  "".rjust(@@depth)+"[--> #{getCaller}]\n"
      @@depth+=2
    end

    # leave method
    def leave()
      @@depth-=2
      print  "".rjust(@@depth)+"[<-- #{getCaller}]\n"
    end

    # returns actual calling method
    def getCaller
      mycall = /\(eval\):\d+:in `(\w+)'/
      caller().each { |stackitem|
        if mycall.match(stackitem)
          return $1
        end
      }
      return "<unknown>"
    end
  end
end
