Skip to content

Commit cc5870a

Browse files
hugovksobolevn
andauthored
[3.12] gh-101100: Fix sphinx warnings in howto/logging.rst (GH-114846) (#114878)
Co-authored-by: Nikita Sobolev <[email protected]>
1 parent 8dcf4fb commit cc5870a

File tree

3 files changed

+36
-24
lines changed

3 files changed

+36
-24
lines changed

Doc/howto/logging.rst

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ custom handlers) are the following configuration methods:
521521

522522
* The :meth:`~Handler.setLevel` method, just as in logger objects, specifies the
523523
lowest severity that will be dispatched to the appropriate destination. Why
524-
are there two :func:`setLevel` methods? The level set in the logger
524+
are there two :meth:`~Handler.setLevel` methods? The level set in the logger
525525
determines which severity of messages it will pass to its handlers. The level
526526
set in each handler determines which messages that handler will send on.
527527

@@ -775,29 +775,29 @@ What happens if no configuration is provided
775775

776776
If no logging configuration is provided, it is possible to have a situation
777777
where a logging event needs to be output, but no handlers can be found to
778-
output the event. The behaviour of the logging package in these
779-
circumstances is dependent on the Python version.
778+
output the event.
780779

781-
For versions of Python prior to 3.2, the behaviour is as follows:
780+
The event is output using a 'handler of last resort', stored in
781+
:data:`lastResort`. This internal handler is not associated with any
782+
logger, and acts like a :class:`~logging.StreamHandler` which writes the
783+
event description message to the current value of ``sys.stderr`` (therefore
784+
respecting any redirections which may be in effect). No formatting is
785+
done on the message - just the bare event description message is printed.
786+
The handler's level is set to ``WARNING``, so all events at this and
787+
greater severities will be output.
782788

783-
* If *logging.raiseExceptions* is ``False`` (production mode), the event is
784-
silently dropped.
789+
.. versionchanged:: 3.2
785790

786-
* If *logging.raiseExceptions* is ``True`` (development mode), a message
787-
'No handlers could be found for logger X.Y.Z' is printed once.
791+
For versions of Python prior to 3.2, the behaviour is as follows:
788792

789-
In Python 3.2 and later, the behaviour is as follows:
793+
* If :data:`raiseExceptions` is ``False`` (production mode), the event is
794+
silently dropped.
790795

791-
* The event is output using a 'handler of last resort', stored in
792-
``logging.lastResort``. This internal handler is not associated with any
793-
logger, and acts like a :class:`~logging.StreamHandler` which writes the
794-
event description message to the current value of ``sys.stderr`` (therefore
795-
respecting any redirections which may be in effect). No formatting is
796-
done on the message - just the bare event description message is printed.
797-
The handler's level is set to ``WARNING``, so all events at this and
798-
greater severities will be output.
796+
* If :data:`raiseExceptions` is ``True`` (development mode), a message
797+
'No handlers could be found for logger X.Y.Z' is printed once.
799798

800-
To obtain the pre-3.2 behaviour, ``logging.lastResort`` can be set to ``None``.
799+
To obtain the pre-3.2 behaviour,
800+
:data:`lastResort` can be set to ``None``.
801801

802802
.. _library-config:
803803

@@ -999,7 +999,7 @@ Logged messages are formatted for presentation through instances of the
999999
use with the % operator and a dictionary.
10001000

10011001
For formatting multiple messages in a batch, instances of
1002-
:class:`~handlers.BufferingFormatter` can be used. In addition to the format
1002+
:class:`BufferingFormatter` can be used. In addition to the format
10031003
string (which is applied to each message in the batch), there is provision for
10041004
header and trailer format strings.
10051005

@@ -1035,7 +1035,8 @@ checks to see if a module-level variable, :data:`raiseExceptions`, is set. If
10351035
set, a traceback is printed to :data:`sys.stderr`. If not set, the exception is
10361036
swallowed.
10371037

1038-
.. note:: The default value of :data:`raiseExceptions` is ``True``. This is
1038+
.. note::
1039+
The default value of :data:`raiseExceptions` is ``True``. This is
10391040
because during development, you typically want to be notified of any
10401041
exceptions that occur. It's advised that you set :data:`raiseExceptions` to
10411042
``False`` for production usage.
@@ -1073,7 +1074,7 @@ You can write code like this::
10731074
expensive_func2())
10741075

10751076
so that if the logger's threshold is set above ``DEBUG``, the calls to
1076-
:func:`expensive_func1` and :func:`expensive_func2` are never made.
1077+
``expensive_func1`` and ``expensive_func2`` are never made.
10771078

10781079
.. note:: In some cases, :meth:`~Logger.isEnabledFor` can itself be more
10791080
expensive than you'd like (e.g. for deeply nested loggers where an explicit

Doc/library/logging.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,12 @@ subclasses. However, the :meth:`!__init__` method in subclasses needs to call
531531

532532
This method should be called from handlers when an exception is encountered
533533
during an :meth:`emit` call. If the module-level attribute
534-
``raiseExceptions`` is ``False``, exceptions get silently ignored. This is
534+
:data:`raiseExceptions` is ``False``, exceptions get silently ignored. This is
535535
what is mostly wanted for a logging system - most users will not care about
536536
errors in the logging system, they are more interested in application
537537
errors. You could, however, replace this with a custom handler if you wish.
538538
The specified record is the one which was being processed when the exception
539-
occurred. (The default value of ``raiseExceptions`` is ``True``, as that is
539+
occurred. (The default value of :data:`raiseExceptions` is ``True``, as that is
540540
more useful during development).
541541

542542

@@ -1477,6 +1477,18 @@ Module-Level Attributes
14771477

14781478
.. versionadded:: 3.2
14791479

1480+
.. attribute:: raiseExceptions
1481+
1482+
Used to see if exceptions during handling should be propagated.
1483+
1484+
Default: ``True``.
1485+
1486+
If :data:`raiseExceptions` is ``False``,
1487+
exceptions get silently ignored. This is what is mostly wanted
1488+
for a logging system - most users will not care about errors in
1489+
the logging system, they are more interested in application errors.
1490+
1491+
14801492
Integration with the warnings module
14811493
------------------------------------
14821494

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Doc/extending/extending.rst
2121
Doc/glossary.rst
2222
Doc/howto/descriptor.rst
2323
Doc/howto/enum.rst
24-
Doc/howto/logging.rst
2524
Doc/library/2to3.rst
2625
Doc/library/aifc.rst
2726
Doc/library/ast.rst

0 commit comments

Comments
 (0)