title: Rails logger formatting - insert method name calling logger method
body: <p>I want to insert name of the method calling the logger methods into my log files.  Not the whole stack trace, but the class, method and/or line number would be great.</p>
  
  <p>In any method, one can use <code>caller</code> to get an array of strings, each of which contains the file, line number and method name.  I've come up with a pretty awful kludge using regexes and <code>Enumerable#find</code> to try to return the first non-logger stack frame.  I guess it works, but if the locations of the logging Ruby files change in a different version or Rails, or I name my files something to do with logs, it will break.  Same with if I take a given index from the top of the stack (I did this at first, then refactored one thing and naturally it gave me the wrong frame).</p>
  
  <p>Note that I'm not looking to just log the controller or action, as those can be retrieved easily.  Mostly this is for stuff in the <code>lib/</code> directory.</p>
  
  <p>Isn't there an easy way to do this?  I don't want to have to pass in <code>__method__</code> every time I make a logging statement.</p>