[issue932563] logging: need a way to discard Logger objects

Vinay Sajip report at bugs.python.org
Mon Jan 7 15:06:31 CET 2008


Vinay Sajip added the comment:

Antoine, I take your point, but there are a number of ways of doing what
you want, apart from the "extra" context argument:

1. Use your own logger classes which do what you want. It's probably
best to make this a wrapper class so you can define different ones for
different needs.
2. Use a non-string as your message. The "message" object passed to
logging can be any object - str() is called on this to get the actual
message.
3. You can use custom Formatter and/or Filter objects to manipulate the
logged message and/or LogRecord instances.

You could pass context information in a number of different ways, but
using a threadlocal might be convenient where the platform supports it.

Any of these approaches should work, and there should be no need to have
a pattern where lots of logging.Logger instances need to be created just
to output context information.

____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue932563>
____________________________________


More information about the Python-bugs-list mailing list