Skip to content

Commit dc01b91

Browse files
sobolevnhugovk
andauthored
gh-101100: Fix sphinx warnings in howto/logging.rst (#114846)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent c9c6e04 commit dc01b91

File tree

3 files changed

+36
-24
lines changed

3 files changed

+36
-24
lines changed

Doc/howto/logging.rst

+22-21
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ custom handlers) are the following configuration methods:
520520

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

@@ -774,29 +774,29 @@ What happens if no configuration is provided
774774

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

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

782-
* If *logging.raiseExceptions* is ``False`` (production mode), the event is
783-
silently dropped.
788+
.. versionchanged:: 3.2
784789

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

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

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

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

801801
.. _library-config:
802802

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

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

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

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

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

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

Doc/library/logging.rst

+14-2
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

@@ -1494,6 +1494,18 @@ Module-Level Attributes
14941494

14951495
.. versionadded:: 3.2
14961496

1497+
.. attribute:: raiseExceptions
1498+
1499+
Used to see if exceptions during handling should be propagated.
1500+
1501+
Default: ``True``.
1502+
1503+
If :data:`raiseExceptions` is ``False``,
1504+
exceptions get silently ignored. This is what is mostly wanted
1505+
for a logging system - most users will not care about errors in
1506+
the logging system, they are more interested in application errors.
1507+
1508+
14971509
Integration with the warnings module
14981510
------------------------------------
14991511

Doc/tools/.nitignore

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Doc/extending/extending.rst
1818
Doc/glossary.rst
1919
Doc/howto/descriptor.rst
2020
Doc/howto/enum.rst
21-
Doc/howto/logging.rst
2221
Doc/library/ast.rst
2322
Doc/library/asyncio-extending.rst
2423
Doc/library/asyncio-policy.rst

0 commit comments

Comments
 (0)