Using Aspect Oriented Programming in Ruby to simplify tracing

Hi,

(Note: This was originally submitted to Ruby-Talk on Google Groups, but it failed to get posted. Hence this was submitted to gmane.comp.lang.ruby.rails using Outlook Express. Hopefully it will have a better fate.)

Is there a simple way to automatically insert a trace function invocation at the start or every method of a rails app? I want to use SimpleTrace to an IO stream or logger.debug to the log file to output each invoked method's name and the arguments it's called with, at a minimum.

I understand that's an easy thing to do with Aspect. I see that there's a patch to Ruby 1.8.2 that introduces a Cut that implements AOP for Ruby.

Has anybody used it? And I wonder whether it would do what I want to do. (I only skimmed it's description.)

Is there some other implementation "out there?"

Regards,

Richard

An alternative idea: Is it possible to put some kind of ":before ShowFilename", with the ShowFilename method defined in top-level code that will be inherited by all other code in the app ... with ShowFilename writing something like _FILENAME_ evaluated in the context of the lower-level code?

I've seen some neat Ruby metaprogramming examples, but I'm too new to Ruby to implement my idea without some guidance.

I got a couple of good answers at http://groups.google.com/group/microsoft.public.office.misc/tree/browse_frm/thread/93649aab3f5e4eec/6e4ae772e7dc0e42?rnum=1&_done=%2Fgroup%2Fmicrosoft.public.office.misc%2Fbrowse_frm%2Fthread%2F93649aab3f5e4eec%3F#doc_6e4ae772e7dc0e42

As far as I'm concerned, this thread is dead.

Richard Lionheart wrote: