bpo-30522: Implemented a method to allow setting a logging.StreamHand…#2921
bpo-30522: Implemented a method to allow setting a logging.StreamHand…#2921vsajip merged 3 commits intopython:masterfrom vsajip:fix-30522
Conversation
pitrou
left a comment
There was a problem hiding this comment.
You probably also want to a NEWS blurb here.
|
|
||
| Sets the instance's stream to the specified value, if it is different. | ||
|
|
||
| :param stream: The stream that the handler should use. |
There was a problem hiding this comment.
Do we support the :param: markup? I don't think I've seen it before in our docs.
There was a problem hiding this comment.
AFAIK it's part of vanilla Sphinx. The docs built OK with it in.
| :meth:`close` method is inherited from :class:`~logging.Handler` and so | ||
| does no output, so an explicit :meth:`flush` call may be needed at times. | ||
|
|
||
| .. method:: setStream(stream) |
There was a problem hiding this comment.
This method needs a versionadded marker.
Doc/library/logging.handlers.rst
Outdated
| set the handler instance's ``terminator`` attribute to the empty string. | ||
| In earlier versions, the terminator was hardcoded as ``'\n'``. | ||
|
|
||
| .. versionchanged:: 3.7 |
There was a problem hiding this comment.
This is better replaced with a versionadded marker for the method itself, see above.
| result = self.stream | ||
| self.acquire() | ||
| try: | ||
| self.flush() |
There was a problem hiding this comment.
Is the flush need here? The only place to write steam is emit(),that already has a flush. If the flush is not needed, the lock is also not needed.
There was a problem hiding this comment.
This may seem a bit defensive but is unlikely to be in performance-critical code, I would have thought.
…ler's stream.
https://bugs.python.org/issue30522