I am fully aware that the problem is in my code, however as getMessage in logging.__init__.py does not catch the exception it is pretty difficult to find the problem without manually inspecting any logging.something statements.

My hack of logging.py is really a hack and I know that this can not be used a patch but I hope that someone with more know how then me knows how to improve the situation.

BTW, using the below hack was enough for me to mind the bad code in my stuff, but it shouldn't have been this difficult.

Traceback (most recent call last):
  File "C:\Python25\lib\logging\__init__.py", line 750, in emit
    msg = self.format(record)
  File "C:\Python25\lib\logging\__init__.py", line 636, in format
    return fmt.format(record)
  File "C:\Python25\lib\logging\__init__.py", line 424, in format
    record.message = record.getMessage()
  File "C:\Python25\lib\logging\__init__.py", line 288, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting


Then I hack logging.py and change line 288 in getMessage from:
            msg = msg % self.args

to:
            try:
                msg = msg % self.args
            except:
                print 'msg: %s' % msg
                print 'args: %s' % self.args
                print traceback.format_exc()

I get the following which helps a lot more in finding were in my code I have the problem:

msg: ping_min: 1
args: replace
Traceback (most recent call last):
  File "C:\Python25\lib\logging\__init__.py", line 290, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting


As mentioned above, I know the above code is not good enough at all, but I hope that maybe Vinay Sajip or someone else with more know how then I have can come up with a patch which will make this type of situation easier.

Werner

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to