From: Paul Brannan Date: 2002-12-08T01:46:19+09:00 Subject: Re: [RCR] Accessor for trace_func I think this proposed RCR is a good idea. It allows trace funcs to be chained together, which is a good thing if you want to trace and profile at the same time. It might be nice if the RCR requested that $trace_func be a hooked global variable. One problem with chaining trace funcs is that it makes it difficult to remove a trace func from the chain. Another solution, if you don't want to wait for Ruby to change, is to redefine set_trace_func: $trace_funcs = [] class Object alias_method :old_set_trace_func, :set_trace_func def set_trace_func(func) $trace_funcs.push(func) end old_set_trace_func proc { |*args| $trace_funcs.each { |f| f.call(*args) } } end Any call to set_trace_func will now add the func to the list of trace funcs instead of replacing the existing one. This makes it easy to remove a trace func (just write a remove_trace_func method), but will have the side effect of breaking code that relies on "set_trace_func nil" removing all existing trace funcs. Paul