print line number and source filename

Shashwat Anand anand.shashwat at gmail.com
Tue Jun 22 13:26:20 EDT 2010


---- begin -----
import logging
logging.basicConfig(level=logging.DEBUG,format="%(asctime)s"
"%(levelname)-5.5s [%(name)s %(module)s:%(funcName)s:%(lineno)d]"
"%(message)s")

def run():
   x = 5
   logging.debug("X = %d" % x)

run()
----- end -----

You can probably use string default concatenation feature of python.
Anyway, am just nitpicking. Loved your example, as I was unaware of logging
module.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100622/d5c0a96f/attachment-0001.html>


More information about the Python-list mailing list