title: Easy way to find "not enough arguments..." in python logging library
body: <p>Do you know any easy way to find a logging call that throws "not enough argumenst for format string". 
  On my workstation I've modified <code>logging/__init__.py</code> to print the msg so I can easily find the line in the source.</p>
  
  <p>But do you have any idea what to do on the testing environment where you can't change python standard library nor run pdb easily?</p>
  
  <p><strong>Note:</strong> The traceback is meaningless, and it is caugth by the logging library.
  Here is an traceback:</p>
  
  <pre><code>  File "/usr/lib/python2.6/logging/handlers.py", line 71, in emit
      if self.shouldRollover(record):
    File "/usr/lib/python2.6/logging/handlers.py", line 144, in shouldRollover
      msg = "%s\n" % self.format(record)
    File "/usr/lib/python2.6/logging/__init__.py", line 648, in format
      return fmt.format(record)
    File "/usr/lib/python2.6/logging/__init__.py", line 436, in format
      record.message = record.getMessage()
    File "/usr/lib/python2.6/logging/__init__.py", line 306, in getMessage
      msg = msg % self.args
  TypeError: not enough arguments for format string
  </code></pre>
  
  <p>And here is the code in standard library that catch the error</p>
  
  <pre><code>    try:
          if self.shouldRollover(record):
              self.doRollover()
          logging.FileHandler.emit(self, record)
      except (KeyboardInterrupt, SystemExit):
          raise
      except:
          self.handleError(record)
  </code></pre>
  
  <p><strong>Solution as suggested by Alex:</strong>
  I've wrapped the getMessage to print the msg and args. Here is the code:</p>
  
  <pre><code>def print_log_record_on_error(func):
      def wrap(self, *args, **kwargs):
          try:
              return func(self, *args, **kwargs)
          except:
              import sys
              print &gt;&gt;sys.stderr, "Unable to create log message msg=%r, args=%r " % (
                                  getattr(self, 'msg', '?'), getattr(self, 'args', '?'))
              raise
      return wrap
  import logging
  logging.LogRecord.getMessage = print_log_record_on_error(logging.LogRecord.getMessage)
  </code></pre>