Repeated output when logging exceptions
sajmikins at gmail.com
Tue Sep 29 01:01:10 CEST 2009
On Mon, Sep 28, 2009 at 4:38 PM, John Gordon <gordon at panix.com> wrote:
> In <6bce12c3-f2d9-450c-89ee-afa4f21d50c8 at h30g2000vbr.googlegroups.com> Vinay Sajip <vinay_sajip at 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 exception handlers. All that
>> stuff with temporary files seems completely unnecessary, even with Python
> I didn't know about the exception() method. Thanks!
>> In general, avoid adding handlers more than once - which you are
>> almost guaranteed to not avoid if you do this kind of processing in a
>> constructor. If you write your applications without using the
>> exceptionLogger class (not really needed, since logging exceptions
>> with tracebacks is part and parcel of the logging package's
>> functionality since its introduction with Python 2.3), what
>> functionality do you lose?
> I'm trying to encapsulate all the setup work that must be done before any
> actual logging occurs: setting the debugging level, choosing the output
> filename, declaring a format string, adding the handler, etc.
> If I didn't do all that in a class, where would I do it?
Put it in a module. :]
> John Gordon A is for Amy, who fell down the stairs
> gordon at panix.com B is for Basil, assaulted by bears
> -- Edward Gorey, "The Gashlycrumb Tinies"
More information about the Python-list