[Python-Dev] PEP282 and the warnings framework
Wed, 15 May 2002 14:25:16 +0200
I've reread PEP 282 (the logging PEP) and much of what I read
reminded me of the warning framework.
Both systems are responsible for reporting (or ignoring) messages.
Both associate messages with locations in the source where the
messages originated and both have a way to configure what to report
and what to ignore.
So I guess it would make sense to somehow merge the two APIs.
And looking at the warning framework suggests a different way
of handling log levels/types: Instead of specifying types
with integer constants and configuring what to log with a
threshold value, we could have a class hierarchy of message
types similar to the hierarchy for warning types:
This hierarchy is customizable with user defined classes:
Configuration would be similar to the configuration for the
warnings framework, i.e. it would be possible to specify which
Message classes should be logged and which shouldn't: The filter
simply calls isinstance() to check if the message should
Calling the logging function would be similar to calling
warnings.warn: You can either pass a message string and a
message class or a message instance, i.e.
logger.log("disk full", log.DiskFullMessage)
Logging exceptions with this API is then simple and natural:
Does this make sense and if yes, do we still have time to change
the PEP/implementation until 2.3?