[issue21608] logging.handlers.HTTPHandler.setFormatter() has no effect
Bikram Zesto II added the comment: I see what you are saying about implementation kludginess and will likely subclass just to get my app done. On the other hand, I think the POLA(stonishment) violation of ignoring format-related configuration of the Handler (even tho it is a subclass) matters too :-) Was not thinking a Formatter should be put _into_ mapLogRecord. More like idly wondering if mapLogRecord could be implemented as a Formatter. If this sounds like a non-kludge you would be interested in I can work on that. Added benefit being that users could override without subclassing. Maybe this is more like a documentation issue (since there is no indication that HTTPHandler does not/cannot use a Formatter like other of Handlers? -- keywords: +patch status: pending - open Added file: http://bugs.python.org/file35410/logging.handlers.txt.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21608 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21608] logging.handlers.HTTPHandler.setFormatter() has no effect
Vinay Sajip added the comment: As far as POLA is concerned, IMO serializing to the HTTP request format isn't really a text formatting operation in the same way as for most other handlers. The point is, even if you could have a Formatter handle the operation, you can't usefully share this Formatter with other handlers (which you refer to in your initial post), unless you really want to have format lines such as a=bc=de=f output to console or file, say - which is unlikely to be a common requirement. I don't expect to make any changes in this area - as I mentioned earlier, because (a) backward compatibility and (b) IMO it will surprise more people than the current approach (IIRC no one else has raised this or a similar issue in the 10+ years that logging has been in Python). BTW, I am happy to update the documentation for HTTPHandler to indicate that it can't sensibly use a Formatter. I'll do this soon, and that change will close this issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21608 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21608] logging.handlers.HTTPHandler.setFormatter() has no effect
Roundup Robot added the comment: New changeset e5373bfbe76b by Vinay Sajip in branch '2.7': Issue #21608: Updated HTTPHandler documentation. http://hg.python.org/cpython/rev/e5373bfbe76b New changeset 220bed23696e by Vinay Sajip in branch '3.4': Issue #21608: Updated HTTPHandler documentation. http://hg.python.org/cpython/rev/220bed23696e New changeset 69011f6ce573 by Vinay Sajip in branch 'default': Closes #21608: Merged documentation update from 3.4. http://hg.python.org/cpython/rev/69011f6ce573 -- nosy: +python-dev resolution: not a bug - fixed stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21608 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21608] logging.handlers.HTTPHandler.setFormatter() has no effect
New submission from Bikram Zesto II: HTTPHandler instance will assign a Formatter to format() but emit() never calls self.format(record) so it has no effect. I know mapLogRecord() does something like this now but would like to reuse Formatters across Handlers instead of subclassing HTTPHandler just for HTTP logging. Does it make sense to assign mapLogRecord by default to self.format but allow it to be over-ridden like other Handlers? -- components: Library (Lib) messages: 219365 nosy: bk2zsto priority: normal severity: normal status: open title: logging.handlers.HTTPHandler.setFormatter() has no effect type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21608 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21608] logging.handlers.HTTPHandler.setFormatter() has no effect
Changes by Berker Peksag berker.pek...@gmail.com: -- nosy: +vinay.sajip ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21608 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21608] logging.handlers.HTTPHandler.setFormatter() has no effect
Vinay Sajip added the comment: HTTPHandler doesn't exactly format text for output - it encodes the LogRecord fields into an HTTP GET or POST request, and sends that request to a web server. Since this formatting is determined by the HTTP protocol, it is not possible to share it with formatting for other destinations (like console or file). I don't think a patch which somehow shoehorns a Formatter into mapLogRecord() will be acceptable, both for reasons of backward compatibility and also because formatting in general is not the same as encoding for HTTP, and trying to push the two things together seems kludgy. I advise you to subclass HttpHandler if its default behaviour doesn't work for you. After all, that's why we have classes in Python :-) -- resolution: - not a bug status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21608 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com