title: How to get current file and line number in Ruby?
body: <p>I want to implement a log function like this:</p>
  
  <pre><code>def mylog(str)
     puts __FILE__, ":"__LINENO__, ":", str  # Here how to get __FILE__ and __LINENO__ is my question.
  end
  </code></pre>
  
  <p>When I call <code>mylog</code>:</p>
  
  <pre><code>mylog 'hello' # say I call this in my.rb line 10
  </code></pre>
  
  <p>I expect output:</p>
  
  <pre><code>my.rb:10:hello
  </code></pre>
  
  <p>Please help give right implementation of <code>mylog</code> function.</p>