470,849 Members | 1,020 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

simple question


i have created a logger
self.logger = logging.getLogger('smsapp')
hdlr = logging.FileHandler('logs/smsapp.log')
formatter = logging.Formatter ('%(asctime)s %(levelname)s %(message)s')

when i log an error
self.logger.error("Illegal date index, " str(dateIndex))
i get an error in my code
Traceback (most recent call last):
File "/usr/local/lib/python2.3/logging/__init__.py", line 674, in emit
msg = self.format(record)
File "/usr/local/lib/python2.3/logging/__init__.py", line 567, in format
return fmt.format(record)
File "/usr/local/lib/python2.3/logging/__init__.py", line 362, in format
record.message = record.getMessage()
File "/usr/local/lib/python2.3/logging/__init__.py", line 233, in
msg = msg % self.args
TypeError: not all arguments converted during string formatting

dateIndex is an int


This message was sent using IMP, the Internet Messaging Program.
Jul 18 '05 #1
1 1876
Ajay wrote:
self.logger.error("Illegal date index, " str(dateIndex))

I think you meant

self.logger.error("Illegal date index ", str(dateIndex))

error(fmt, arg1, arg2, ..., argN)

is just a convenient alternative to

error(fmt % (arg1, arg2, ..., argN))


self.logger.error("Illegal date index %s", dateIndex)


self.logger.error("Illegal date index " + str(dateIndex))

should both work.


Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Patchwork | last post: by
1 post views Thread by Proteus | last post: by
2 posts views Thread by Raskolnikow | last post: by
3 posts views Thread by Peter | last post: by
7 posts views Thread by abcd | last post: by
14 posts views Thread by Giancarlo Berenz | last post: by
30 posts views Thread by galiorenye | last post: by
10 posts views Thread by Phillip Taylor | last post: by
17 posts views Thread by Chris M. Thomasson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.