[Python-Dev] Re: PEP 282 comments (original) (raw)

Barry A. Warsaw barry@zope.com
Thu, 21 Mar 2002 01:13:28 -0500


"GvR" == Guido van Rossum <guido@python.org> writes:

GvR> If this use case is rare enough, maybe a better approach
GvR> would be to let you format it yourself using the traceback
GvR> module?

This reminds me of another use case for logging, which may or may not be covered by PEP 282.

When an uncaught exception happens in Mailman (i.e. it percolates up to the "main loop" of the current process), I always want to log it somewhere because it definitely indicates a bug.

If this exception happens in the web interface, I will usually log the exception in some file, and also format the exception into html for output in the browser, /except/ when a `stealth mode' is enabled. The traceback can be considered sensitive information, so when debugging we turn stealth mode off, but we always ship with stealth mode on. In stealth mode, we still always log the traceback to a file, but we never output the traceback onto the web page.

It would also be great if I can create a logger that knows how to tee its output to multiple sinks. If I understand the PEP correctly, I think I would use two standard formatters, a plaintext formatter and an html formatter. I'd then have two custom handlers, one which outputs to html mindful of the current stealth mode, and one which tees the LogRecord to two sub-handlers (i.e. the stealth-mode-aware handler, and the normal to-file handler).

Does this seem reasonable given PEP 282's current proposal?

-Barry