-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-30522: Implemented a method to allow setting a logging.StreamHand… #2921
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably also want to a NEWS blurb here.
Doc/library/logging.handlers.rst
Outdated
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK it's part of vanilla Sphinx. The docs built OK with it in.
@@ -59,13 +59,25 @@ and :meth:`flush` methods). | |||
: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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method needs a versionadded
marker.
Doc/library/logging.handlers.rst
Outdated
.. versionchanged:: 3.2 | ||
The ``StreamHandler`` class now has a ``terminator`` attribute, default | ||
value ``'\n'``, which is used as the terminator when writing a formatted | ||
record to a stream. If you don't want this newline termination, you can | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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