title: Python, logging pathname in decorator
body: <p>When I logging an error in a decorator, the logging <code>pathname</code> is not what I want.</p>
  
  <p>logging.conf:</p>
  
  <pre><code>[loggers]
  keys=root
  [handlers]
  keys=console
  [formatters]
  keys=console
  [logger_root]
  ...
  [handler_console]
  ...
  [formatter_console]
  format=%(levelname)s - File "%(pathname)s", line %(lineno)s, %(funcName)s: %(message)s
  </code></pre>
  
  <p>Nomally, logging an error in file <code>/home/lizs/test/app.py</code>:</p>
  
  <pre><code>def app():
      try:
          a   # error, on line 12
      except Exception, err:
          logging.getLogger().error(str(err))
  </code></pre>
  
  <p>Debug message on console:</p>
  
  <pre><code>ERROR - File "/home/lizs/test/app.py", line 12, app: global name 'a' is not defined
  </code></pre>
  
  <p>The above logging <code>pathname</code>(/home/lizs/test/app.py) is what I want. But when I use a decorator:</p>
  
  <p><code>/home/lizs/test/app.py</code>:</p>
  
  <pre><code>from decorators import logging_decorator
  
  
  @logging_decorator
  def app():
     a
  </code></pre>
  
  <p><code>/home/lizs/test/decorators.py</code>:</p>
  
  <pre><code>def logging_decorator(func):
      def error_log():
          try:
              func()  # on line 10
          except Exception, err:
              logging.getLogger().error(str(err))
      return error_log
  </code></pre>
  
  <p>The debug message:</p>
  
  <pre><code>ERROR - File "/home/lizs/test/decorators.py", line 10, error_log: global name 'a' is not defined
  </code></pre>
  
  <p>Now, the logging <code>pathname</code> is a pathname of the decorator (/home/lizs/test/decorators.py).</p>
  
  <p>How to set the logging <code>pathname</code> to <code>/home/lizs/test/app.py</code> when I use decorator.</p>