Issue 1032206: Add API to logging package to allow intercooperation. (original) (raw)
This set of patches implements two simple ways in which the logging package could be extended to allow more than one body of code to customize the base Logger class.
The first patch (and doc patch) implements a "getLoggerClass()" function symmentrical to the existing "setLoggerClass()" function.
The second patch instead renames the internal "_loggerClass" variable to "loggerClass", leaving the old setLoggerClass() function for compatibility.
The problem with the logging module at present is that if I wish to define extra functionality in the Logger class for use with my application or package, and another package that I make use of does the same, then one set of Logger class customisations will be lost.
Using the above patches, the standard way to extend Logger would go from:
class MyLogger(logging.Logger): ...
to:
class MyLogger(logging.getLoggerClass()): ...
or alternatively for the second patch:
class MyLogger(logging.loggerClass): ...
Thanks,
David.