[issue932563] logging: need a way to discard Logger objects
Vinay Sajip added the comment: LoggerAdapter class added to trunk. Documentation also updated. -- resolution: - fixed status: open - closed Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Vinay Sajip added the comment: I've posted a proposal to python-list: you can view via http://groups.google.co.uk/group/comp.lang.python/browse_frm/thread/336eb031c85758fa or http://article.gmane.org/gmane.comp.python.general/553877 Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
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 [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Changes by Vinay Sajip: -- priority: high - normal Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Fred L. Drake, Jr. added the comment: Ideally, it would be best if loggers didn't live forever behind the scenes if they have no non-default configuration, but documenting their long-lived nature and the recommended alternate ways to deal with getting additional context information into the results. Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Vinay Sajip added the comment: Ok, but let's continue the discussion on comp.lang.python, as this is probably not the best place for an extended discussion. I'll post there soon with a proposal. Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Fred L. Drake, Jr. added the comment: Please be sure to post a link to the thread here, as not everyone here reads comp.lang.python. Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Antoine Pitrou added the comment: I don't follow comp.lang.python either, so I'd be grateful if you give a link to the gmane thread ;) I hope we can find an useful solution to this limitation, logging is a very important task and the stdlib should satisfy all common wishes IMO. Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Vinay Sajip added the comment: There's probably no need. Fred's initial reason for wanting this (usage of connection-specific loggers, which would be an anti-pattern in my book) was later solved by him using an application-specific wrapper. Also, changes made to logging after this issue was created make it easier to include context information (e.g. connection IDs) in logging calls. So: I don't think it is good behaviour for any application to create a large (= potentially unbounded) set of loggers. The number of loggers created should be dependent on the granularity of logging which the application developer wants to use. If this approach is followed, the number of loggers is unlikely to lead to memory hogging by the logging package. So, I propose to close this ticket now, but anyone can of course reopen it if they think there is still an issue here which needs addressing. I will review the docs to see if I need to clarify that loggers should not be created on a per-connection (or analogous) basis. -- resolution: - out of date status: open - closed Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Antoine Pitrou added the comment: Well, I have met this problem too some time ago, so could you please reopen the bug? Saying creating a lot of connection-bound logger objects is an antipattern doesn't help. It's the only simple way of doing something useful: have a logging target with different messages based on IP address (or whatever else, e.g. user name). Also, when you say changes made to logging after this issue was created make it easier to include context information (e.g. connection IDs) in logging calls, that doesn't address the problem, because you have to include that context information in every logging class while what you really want to do is to include it once in the call to getLogger()... Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Antoine Pitrou added the comment: s/in every logging class/in every logging call/, sorry. Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Antoine Pitrou added the comment: This could probably be solved with an optional argument to getLogger() and a weakref. Do you want me to write a patch? -- nosy: +pitrou Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue932563] logging: need a way to discard Logger objects
Changes by Christian Heimes: -- versions: +Python 2.6 Tracker [EMAIL PROTECTED] http://bugs.python.org/issue932563 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com