Skip to content
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

Merged
merged 3 commits into from
Jul 30, 2017
Merged

bpo-30522: Implemented a method to allow setting a logging.StreamHand… #2921

merged 3 commits into from
Jul 30, 2017

Conversation

vsajip
Copy link
Member

@vsajip vsajip commented Jul 27, 2017

@vsajip vsajip self-assigned this Jul 28, 2017
Copy link
Member

@pitrou pitrou left a 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.


Sets the instance's stream to the specified value, if it is different.

:param stream: The stream that the handler should use.
Copy link
Member

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.

Copy link
Member Author

@vsajip vsajip Jul 29, 2017

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)
Copy link
Member

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.

.. 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
Copy link
Member

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.

@vsajip vsajip merged commit 2543f50 into python:master Jul 30, 2017
@vsajip vsajip deleted the fix-30522 branch July 30, 2017 09:41
result = self.stream
self.acquire()
try:
self.flush()
Copy link

@qingyunha qingyunha Aug 3, 2017

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.

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants