Re: Repeated output when logging exceptions

2009-09-30 Thread Chris Withers
Vinay Sajip wrote: I'm not sure why you need all the code you've posted. The logging package allows you to add tracebacks to your logs by using the exception() method, which logs an ERROR with a traceback and is specifically intended for use from within exception handlers. You can also use

Re: Repeated output when logging exceptions

2009-09-30 Thread Chris Withers
John Gordon wrote: If I didn't do all that in a class, where would I do it? I find the configureLoggers method of ZConfig most convenient for this: http://pypi.python.org/pypi/ZConfig cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting -

Re: Repeated output when logging exceptions

2009-09-29 Thread Vinay Sajip
On Sep 28, 9:38 pm, John Gordon gor...@panix.com wrote: If I didn't do all that in a class, where would I do it? You could, for example, use the basicConfig() function to do it all for you. import logging logging.basicConfig(filename='/path/to/my/log',level=logging.DEBUG) logging.debug('This

Re: Repeated output when logging exceptions

2009-09-28 Thread John Gordon
In 6bce12c3-f2d9-450c-89ee-afa4f21d5...@h30g2000vbr.googlegroups.com Vinay Sajip vinay_sa...@yahoo.co.uk writes: The logging package allows you to add tracebacks to your logs by using the exception() method, which logs an ERROR with a traceback and is specifically intended for use from within

Re: Repeated output when logging exceptions

2009-09-28 Thread Simon Forman
On Mon, Sep 28, 2009 at 4:38 PM, John Gordon gor...@panix.com wrote: In 6bce12c3-f2d9-450c-89ee-afa4f21d5...@h30g2000vbr.googlegroups.com Vinay Sajip vinay_sa...@yahoo.co.uk writes: The logging package allows you to add tracebacks to your logs by using the exception() method, which logs an

Re: Repeated output when logging exceptions

2009-09-25 Thread Vinay Sajip
On Sep 24, 8:43 pm, John Gordon gor...@panix.com wrote: Why is this happening?  I suspect it's because I'm declaring two instances of the exceptionLogger class, which ends up calling logger.addHandler() twice.  Is that right? Yes, that's why you get duplicated lines in the log. What would

Repeated output when logging exceptions

2009-09-24 Thread John Gordon
I wrote some code to handle and log exceptions in my application. It works well, but it produces double output for each exception. How can I fix this? Here's the pared-down code: - main.py import exceptionLogger import doStuff exlog = exceptionLogger.exceptionLogger() stuff =