Skip to content

Commit 22906c2

Browse files
authored
Merge pull request #12094 from anntzer/logging
Fine-tune logging notes in contributing.rst.
2 parents 603b4fa + 9867019 commit 22906c2

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

doc/devel/contributing.rst

+15-13
Original file line numberDiff line numberDiff line change
@@ -449,29 +449,31 @@ Then they will receive messages like::
449449
Which logging level to use?
450450
~~~~~~~~~~~~~~~~~~~~~~~~~~~
451451

452-
There are five levels at which you can emit messages.
453-
`logging.critical` and `logging.error`
454-
are really only there for errors that will end the use of the library but
455-
not kill the interpreter. `logging.warning` overlaps with the
456-
``warnings`` library. The
457-
`logging tutorial <https://docs.python.org/3/howto/logging.html#logging-basic-tutorial>`_
458-
suggests that the difference
459-
between `logging.warning` and `warnings.warn` is that
460-
`warnings.warn` be used for things the user must change to stop
461-
the warning, whereas `logging.warning` can be more persistent.
452+
There are five levels at which you can emit messages. `logging.critical` and
453+
`logging.error` are really only there for errors that will end the use of the
454+
library but not kill the interpreter. `logging.warning` overlaps with the
455+
`warnings` library. The `logging tutorial`_ suggests that the difference
456+
between `logging.warning` and `warnings.warn` is that `warnings.warn` should
457+
be used for things the user must change to stop the warning (typically in the
458+
source), whereas `logging.warning` can be more persistent. Moreover, note
459+
that `warnings.warn` will by default only emit a given warning *once*, whereas
460+
`logging.warning` will display the message every time it is called.
462461

463462
By default, `logging` displays all log messages at levels higher than
464463
`logging.WARNING` to `sys.stderr`.
465464

466465
Calls to `logging.info` are not displayed by default. They are for
467466
information that the user may want to know if the program behaves oddly.
468467
For instance, if an object isn't drawn because its position is ``NaN``,
469-
that can usually be ignored, but a mystified user could set
468+
that can usually be ignored, but a mystified user could call
470469
``logging.basicConfig(level=logging.INFO)`` and get an error message that
471470
says why.
472471

473-
`logging.debug` is the least likely to be displayed, and hence can
474-
be the most verbose.
472+
`logging.debug` is the least likely to be displayed, and hence can be the most
473+
verbose. "Expected" code paths (e.g., reporting normal intermediate steps of
474+
layouting or rendering) should only log at this level.
475+
476+
.. _logging tutorial: https://docs.python.org/3/howto/logging.html#logging-basic-tutorial
475477

476478
.. _custom_backend:
477479

0 commit comments

Comments
 (0)