From: Rich Kilmer Date: 2002-10-02T00:51:40+09:00 Subject: RE: current method This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C26940.428F82C0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit you could do something like this: def meth log "Message" end def log(message) puts caller[0]+" "+message end meth #=> test.rb:2:in `meth' Message The caller array lists the file/line#/method that called the current method, so log is called by "meth" and can output that There may be a better way. regards, rich -----Original Message----- From: Volkmann, Mark [mailto:Mark.Volkmann@AGEDWARDS.com] Sent: Tuesday, October 01, 2002 11:08 AM To: ruby-talk ML Subject: current method Is there a way to programmatically determine the name of the method that is currently being executed? I'd like to use this for logging purposes. ************************************************************************ *********** WARNING: All e-mail sent to and from this address will be received or otherwise recorded by the A.G. Edwards corporate e-mail system and is subject to archival, monitoring or review by, and/or disclosure to, someone other than the recipient. ************************************************************************ ************ ------=_NextPart_000_0009_01C26940.428F82C0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message
you=20 could do something like this:
 
def=20 meth
  log "Message"
end
 
def=20 log(message)
  puts caller[0]+" = "+message
end
 
meth=20 #=3D> test.rb:2:in `meth' Message
 
The=20 caller array lists the file/line#/method that called the current method, = so log=20 is called by "meth" and can output that
 
There=20 may be a better way.
 
regards,
 
rich

-----Original Message-----
From: = Volkmann, Mark=20 [mailto:Mark.Volkmann@AGEDWARDS.com]
Sent: Tuesday, October = 01,=20 2002 11:08 AM
To: ruby-talk ML
Subject: current=20 method

Is there a way to programmatically determine the = name of the=20 method that is currently being executed?
I'd = like to=20 use this for logging purposes.



********************************************************= ***************************
WARNING:=20 All e-mail sent to and from this address will be received = or
otherwise=20 recorded by the A.G. Edwards corporate e-mail system and is
subject = to=20 archival, monitoring or review by, and/or disclosure to,
someone = other than=20 the=20 = recipient.
***********************************************************= *************************
------=_NextPart_000_0009_01C26940.428F82C0--