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

[master] Logging Configuration and Logger Initialization #66633

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

madavarajK
Copy link

What does this PR do?

Logging Configuration and Logger Initialization

Added logging configuration at the beginning of the script.
Initialized a logger instance using logging.getLogger(name).
Enhanced Error Handling

Replaced print statements with logger calls (logger.error for errors).
Added specific exception handling for NoCredentialsError and PartialCredentialsError.
Updated Docstring

Added a docstring for the get_repo_json_file_contents function to describe its purpose and parameters.
Improved Exception Messages

Provided more informative error messages within the exception handlers to aid debugging.

What issues does this PR fix or reference?

Fixes

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes/No

Please review Salt's Contributing Guide for best practices, including the
PR Guidelines.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@madavarajK madavarajK requested a review from a team as a code owner June 12, 2024 03:36
@madavarajK madavarajK requested a review from twangboy June 12, 2024 03:36
Copy link

welcome bot commented Jun 12, 2024

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@salt-project-bot-prod-environment salt-project-bot-prod-environment bot changed the title Logging Configuration and Logger Initialization [master] Logging Configuration and Logger Initialization Jun 12, 2024
Copy link
Contributor

@twangboy twangboy left a comment

Choose a reason for hiding this comment

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

This is also gonna need a changelog and some tests. Look for caplog for examples of how to test logging.

import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use log instead of logger here. That stays in line with the rest of the project.

Copy link
Contributor

Choose a reason for hiding this comment

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

We absolutely should not be calling basicConfig here.

Comment on lines +22 to +25
logger.error(
"Please run 'python -m pip install -r requirements/static/ci/py{}.{}tools.txt'".format(
*sys.version_info
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest using the the formatting capability of logger instead of calling format explicitly. Something like

log.error("Please run 'python -m pip install -r requirements/static/ci/py%s.%stools.txt'", *sys.version_info)

import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Copy link
Contributor

Choose a reason for hiding this comment

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

We absolutely should not be calling basicConfig here.

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.

None yet

4 participants