[Python-Dev] Planned changes to logging
Vinay Sajip
vinay_sajip at red-dove.com
Sun Jun 27 18:52:03 EDT 2004
I'm planning to check in some changes to the logging package. I'd appreciate
comments on the following:
1. A backwards-compatible change to basicConfig(), making simple
configuration of logging easier than before. For example, to change the
level of the root logger to DEBUG:
logging.basicConfig(level=logging.DEBUG)
For example, to change the message format:
logging.basicConfig(format="%(asctime)s %(levelname)-5s %(message)s")
To log to a file in append mode (for write mode, add a filemode="w"
argument):
logging.basicConfig(filename="/logs/myapp.log")
To log to an existing stream:
s = open("/logs/myapp.log", "w")
...
logging.basicConfig(stream=s)
2. Refactoring of RotatingFileHandler into BaseRotatingHandler and
RotatingFileHandler. The reason for this is the addition of a new class,
TimedRotatingFileHandler, which rotates files based on time-dependent
criteria. (See SF patch #921318 for more details).
3. Logger.log() changed to throw a TypeError if raiseExceptions is set and
the level passed in is not an integer.
If the changes seem generally acceptable, then I'll also add a section in
the docs which describes the above basic use cases under a "Basic use of the
logging package" section which appears earlier in the logging docs than it
does currently. Except for the documentation changes, I'm planning to commit
by 3 July.
Thanks,
Vinay
More information about the Python-Dev
mailing list