"Christoph Neubauer" <christoph.neubauer / siemens.com> schrieb im
Newsbeitrag news:cdghds$plc$1 / news.siemens.at...
> Hi Rubyists !
>
> I'm  using ruby 1.6.8 (2002-12-24) [i586-mswin32]
> What I tinkered for tracing is (simplified) this:

Do you know Kernel#set_trace_func() ?  That'll do what you need much more
easily IMHO.
http://www.ruby-doc.org/docs/rdoc/1.9/classes/Kernel.html#M001573

(It's already present in 1.6.8)

> My question is:
> How do I know the names of the formal arguments of the actual caller of
> TraceEntry ?

You can't other that providing them explicitely, for example by using a
hash:

def traceEntry (args={})
    puts "\n"
    puts ("ENTRY " + caller[0])
    args.each {|name, arg| puts "ARG: #{name}=#{arg}"}
end

def traceExit
    puts ("EXIT " + caller[0])
    puts "\n"
end

and then do

def method1 (arg1 = 0, arg2 = false, arg3 = 'hello')
  traceEntry ("arg1" => arg1, "arg2" => arg2, "arg3" => arg3)
  begin
    # do some stuff
  ensure
    # record even in case of an exception
    traceExit
  end
end


Kind regards

    robert