On Sat, Jul 12, 2003 at 07:58:16AM +0900, Moses Hall wrote:
> Greetings.
> 
> I'm a recent Ruby convert and I absolutely love it. No other lingo looks
> so much (or for that matter, even vaguely) like pseudocode! Great stuff.
> 
> Anyway, in my code I found myself keeping an array of the methods for
> which I wanted verbose debugging info, to get info printed only
> during the execution of particular method(s). Previously I would check
> in each method whether its name was in the array:
> 
>   def method1(x)
>    debug = @@debug.member? "method1"
>    printf "method1 called with %s\n", x.inspect if debug
>    ...
>   end
> 
> Then I came up with a way to reduce this to a "debug" method, which gets the
> stack and grabs the (calling) method's name and then returns true if that
> is in the global array o' method names.
> 
> It's kinda skanky, anyone have a better, safer, cleaner,
> and/or cooler way to do this?

You can use aspects (AspectR) to add logging to the desired methods.

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

* dpkg ponders: 'C++' should have been called 'D'
	-- #Debian