[issue18541] LoggerAdapter example is counter-productive

Vinay Sajip report at bugs.python.org
Wed Jul 24 15:45:47 CEST 2013


Vinay Sajip added the comment:

That's not quite right. The recommended way *is* to override the process() method. From the page you linked to:

"If you need a different method, e.g. if you want to prepend or append the contextual information to the message string, you just need to subclass LoggerAdapter and override process() to do what you need."

That does not have a specific example, as it seems simple enough to understand as stated.

The example you mention shows something else - how you would adapt an existing class (which might have information to go into the log) so that it could be passed (instead of a dict) to the LoggerAdapter initialiser. Possibly I could put this example into a separate section "Adapting an existing class to provide context information for logging" - this would make it clear that it's a separate use case and not the primary use case when using LoggerAdapter. The text seems clear enough,

"illustrates what dict-like behaviour is needed from an arbitrary ‘dict-like’ object for use in the constructor", but splitting it out into a separate section will make it easier for those who are speed-reading the docs.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18541>
_______________________________________


More information about the Python-bugs-list mailing list