Skip to content

gh-98731: Improvements to the logging documentation #101618

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

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

quicknir
Copy link
Contributor

@quicknir quicknir commented Feb 6, 2023

This PR is probably just a starting point, but hopefully we can begin with this and iterate.

@ghost
Copy link

ghost commented Feb 6, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@@ -26,9 +26,11 @@ When to use logging
^^^^^^^^^^^^^^^^^^^

Logging provides a set of convenience functions for simple logging usage. These
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since your change refers to using logger methods rather than the convenience functions, I'd remove this sentence and go with something like "You can access logging functionality by creating a logger via ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

:func:`critical`. To determine when to use logging, see the table below, which
states, for each of a set of common tasks, the best tool to use for it.
can be accessed by creating a logger via ``logger = getLogger(__name__)``, and
then calling :func:`logger.debug`, :func:`logger.info`, :func:`logger.warning`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use : meth: here rather than :func: maybe? This applies to similar usages below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

then calling :func:`logger.debug`, :func:`logger.info`, :func:`logger.warning`,
:func:`logger.error` and :func:`logger.critical`. To determine when to use
logging, see the table below, which states, for each of a set of common tasks,
the best tool to use for it.

+-------------------------------------+--------------------------------------+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you actually build this documentation locally? If you did, not sure how it got past these errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not. I will try to build them locally and message if I have issues.

module, like ``logging.debug``, rather than creating a logger and calling
functions on it. These functions operation on the root logger, but can be useful
as they will call ``basicConfig`` for you if it has not been called yet, like in
this example. In larger programs you'll usually want to control this call
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this example. In larger programs you'll usually want to control this call
this example. In larger programs you'll usually want to control the logging configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

| server process) | appropriate for the specific error |
| | and application domain |
+-------------------------------------+--------------------------------------+

The logging functions are named after the level or severity of the events
The functions are named after the level or severity of the events
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The functions are named after the level or severity of the events
The logger methods are named after the level or severity of the events

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Logs a message with level :const:`WARNING` on the root logger. The arguments
are interpreted as for :func:`debug`.
Logs a message with level :const:`WARNING` on the root logger. The arguments and behavior
are the otherwise same as for :func:`debug`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
are the otherwise same as for :func:`debug`.
are otherwise the same as for :func:`debug`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Logs a message with level :const:`ERROR` on the root logger. The arguments are
interpreted as for :func:`debug`.
Logs a message with level :const:`ERROR` on the root logger. The arguments and behavior
are the otherwise same as for :func:`debug`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
are the otherwise same as for :func:`debug`.
are otherwise the same as for :func:`debug`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Logs a message with level :const:`CRITICAL` on the root logger. The arguments
are interpreted as for :func:`debug`.
Logs a message with level :const:`CRITICAL` on the root logger. The arguments and behavior
are the otherwise same as for :func:`debug`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
are the otherwise same as for :func:`debug`.
are otherwise the same as for :func:`debug`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Logs a message with level :const:`ERROR` on the root logger. The arguments are
interpreted as for :func:`debug`. Exception info is added to the logging
Logs a message with level :const:`ERROR` on the root logger. The arguments and behavior
are the otherwise same as for :func:`debug`. Exception info is added to the logging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
are the otherwise same as for :func:`debug`. Exception info is added to the logging
are otherwise the same as for :func:`debug`. Exception info is added to the logging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@vsajip
Copy link
Member

vsajip commented May 6, 2023

Also @quicknir please remember to sign the CLA and resolve the build errors.

@vsajip
Copy link
Member

vsajip commented Jul 22, 2023

Hi @quicknir, are you planning to work on this in the near future?

@quicknir
Copy link
Contributor Author

@vsajip Hey, yes, I should have some time to work on this soon.

@vsajip
Copy link
Member

vsajip commented Nov 23, 2023

Hi @quicknir - any idea when you might have time to progress this?

@quicknir
Copy link
Contributor Author

quicknir commented Dec 6, 2023

@vsajip Hey, sorry for the hold up. I think I will have some time in mid January; going to try to make it a goal to have this merged in Jan-Feb.

@vsajip
Copy link
Member

vsajip commented Mar 9, 2024

Any chance you'll be able to work on this soon, @quicknir?

@quicknir
Copy link
Contributor Author

@vsajip hey, I integrated all your feedback, rebased, built the docs locally (fixing another issue in the process). Hopefully we can power this through :-).

@vsajip
Copy link
Member

vsajip commented Mar 12, 2024

Thanks. The docs build is failing because of warnings, I'm not yet sure if it's caused by your changes but hope to look more closely soon.

@quicknir
Copy link
Contributor Author

@vsajip I suspect that they are, they all look like this

Warning: py:meth reference target not found: logger.debug
/home/runner/work/cpython/cpython/Doc/howto/logging.rst:28: WARNING: py:meth reference target not found: logger.debug

But I'm not sure I understand exactly why it's happening.

@vsajip vsajip merged commit 7f418fb into python:main Mar 13, 2024
@vsajip vsajip added the needs backport to 3.11 only security fixes label Mar 13, 2024
@vsajip vsajip added the needs backport to 3.12 only security fixes label Mar 13, 2024
@miss-islington-app
Copy link

Thanks @quicknir for the PR, and @vsajip for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @quicknir for the PR, and @vsajip for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 13, 2024
…01618)

(cherry picked from commit 7f418fb)

Co-authored-by: Nir Friedman <quicknir@gmail.com>
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
@bedevere-app
Copy link

bedevere-app bot commented Mar 13, 2024

GH-116733 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Mar 13, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 13, 2024
…01618)

(cherry picked from commit 7f418fb)

Co-authored-by: Nir Friedman <quicknir@gmail.com>
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
@bedevere-app
Copy link

bedevere-app bot commented Mar 13, 2024

GH-116734 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 13, 2024
@quicknir
Copy link
Contributor Author

@vsajip thanks for your patience, and cheers on merging it :-)

vsajip pushed a commit that referenced this pull request Mar 13, 2024
vsajip pushed a commit that referenced this pull request Mar 13, 2024
vstinner pushed a commit to vstinner/cpython that referenced this pull request Mar 20, 2024
…01618)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
…01618)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…01618)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants