Add some utility methods to Kernel
which will determine the
name of the invoking method by examining the call stack and to determine
the amount of memory currently being used by buryspam.
By default, return the name of the method that called the method that
called invoker
. We can go higher up in the stack by
increasing the frame parameter. Ref:
http://www.ruby-forum.com/topic/75258
# File buryspam.rb, line 167 def invoker(frame = 1) caller[frame] =~ /`([^']*)'/ && $1 || "<main>" end
# File buryspam.rb, line 171 def mem_usage(msg) Logger.debug("#{msg}: memory used: " + %x{/usr/bin/pmap #$$ | /bin/tail -n 1}.strip) end