spice for PEP 282
Here's some spice for the logger recipe. Please season to taste. Abstract ======== The dps.utils.Reporter class (http://docstring.sf.net/dps/utils.py) implements a logger but with *multiple* thresholds per category (stream/channel). Similarly to log4j, there's a "warninglevel" threshold, which determines if a message gets sent to the warning stream (sys.stderr). There's also an "errorlevel" threshold which determines if a message is converted into a *raised exception*, potentially halting processing. And a "debug" flag which turns debug messages on or off independently of the "warninglevel" threshold. I suggest that the Python stdlib logging module adopt some of these features. Background ========== I've been working on the DPS & reStructuredText projects (soon to be merged and officially renamed to "Docutils") on and off for some months now. Docutils will parse texts (files or docstrings) into DOM-like document trees, then convert them to HTML etc. Early on I saw the need to insert "system_message" feedback elements of different levels into the doctree and implemented dps.utils.Reporter. I included thresholds for logging to sys.stderr and raising exceptions, initially with only one setting (like log4j with only the root "category" set). This Reporter class has been very successful As a pointed reminder of how wheels are continually reinvented, I learned about log4j (just before the python-dev effort got underway; I probably read the same message that got Guido started). I already had 4 message levels (what log4j called "logging priorities"), and log4j's notion of "logging categories" seemed a powerful one, so I retrofitted the dps.utils.Reporter class with support for categories. I also added a "debug" category, which I had been handling separately.
participants (1)
-
David Goodger