-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
base: master
Are you sure you want to change the base?
Conversation
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.
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. |
There was a problem hiding this 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__) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
logger.error( | ||
"Please run 'python -m pip install -r requirements/static/ci/py{}.{}tools.txt'".format( | ||
*sys.version_info | ||
) |
There was a problem hiding this comment.
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__) |
There was a problem hiding this comment.
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.
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.