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

Add logger.warning for default and missing mapped values #174

Merged
merged 6 commits into from
Jul 16, 2024

Conversation

aarshgupta24
Copy link
Contributor

Description

added warning log where default value was being used

Commit type

refactor

Issue

Logging warning level if there is no mapping available and the default is being loaded.

Solution

logger.warning is added for default value

Proposed Changes

-added logger.warning in PropertiesManager
-changed info log to warning log

Potential Impact

Help in checking for further problems where default value is being loaded.

Assigned

@AntonioMrtz

@AntonioMrtz
Copy link
Owner

AntonioMrtz commented Jul 16, 2024

Please check https://antoniomrtz.github.io/SpotifyElectron/Git-Convention/ for naming convention for PR

@@ -81,6 +81,8 @@ def _set_attributes(self, config_section: str):
for key, value in self.config.items(config_section):
if value == "":
value = None
if value is None:
Copy link
Owner

Choose a reason for hiding this comment

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

Unify if value is None: inside if value == "": in the same if statement. Use or

@@ -91,7 +93,7 @@ def _load_architecture(self):
if not architecture_type:
architecture_type = DEFAULT_ARCHITECTURE
self.__setattr__(ARCHITECTURE_ENV_NAME, DEFAULT_ARCHITECTURE)
Copy link
Owner

@AntonioMrtz AntonioMrtz Jul 16, 2024

Choose a reason for hiding this comment

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

I think this line has no effect, because line self.__setattr__(ARCHITECTURE_ENV_NAME, architecture_type) is already loading the architecture name. Just delete it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are taking about this line right?
architecture_type = DEFAULT_ARCHITECTURE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or are talking about the whole if block ? @AntonioMrtz

Copy link
Owner

@AntonioMrtz AntonioMrtz Jul 16, 2024

Choose a reason for hiding this comment

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

you are taking about this line right? architecture_type = DEFAULT_ARCHITECTURE

nope. Only self.__setattr__(ARCHITECTURE_ENV_NAME, DEFAULT_ARCHITECTURE) is redundant.

Copy link
Owner

@AntonioMrtz AntonioMrtz left a comment

Choose a reason for hiding this comment

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

Check review msgs

@aarshgupta24 aarshgupta24 changed the title refactor/Add warning-log refactor: Add logger.warning for default and missing mapped values Jul 16, 2024
@AntonioMrtz
Copy link
Owner

@aarshgupta24 No need for prefix in PR name. Use as an example Add Home Page

@aarshgupta24 aarshgupta24 changed the title refactor: Add logger.warning for default and missing mapped values Add logger.warning for default and missing mapped values Jul 16, 2024
@aarshgupta24
Copy link
Contributor Author

@AntonioMrtz , sorry i am bit confused , you as per your review i will remove the redundant log statement that i added but after that no thing much is changed , so should i go through the code once more ? or everything is good and i should just move forward with only the change of info->warning?

@AntonioMrtz
Copy link
Owner

AntonioMrtz commented Jul 16, 2024

@AntonioMrtz , sorry i am bit confused , you as per your review i will remove the redundant log statement that i added but after that no thing much is changed , so should i go through the code once more ? or everything is good and i should just move forward with only the change of info->warning?

Remove the mentioned redudant line and unify both if statements into only 1. Then add the new logging.warning inside the unified if statement 😀. I saw that you deleted the logging statement., theres no need for that.

@@ -81,8 +81,6 @@ def _set_attributes(self, config_section: str):
for key, value in self.config.items(config_section):
if value == "":
value = None
if value is None:
properties_manager_logger.warning(f"Using None for {key} in {config_section}")
Copy link
Owner

Choose a reason for hiding this comment

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

Unify this statement with the one above. Something like if value=="" or None. Then inside join both value=None and the new log message

@aarshgupta24
Copy link
Contributor Author

@AntonioMrtz , im done with the changes please go through them and tell me if something else is needed

@@ -79,8 +79,9 @@ def _set_attributes(self, config_section: str):

"""
for key, value in self.config.items(config_section):
if value == "":
if value == "" or None:
Copy link
Owner

Choose a reason for hiding this comment

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

I think last comment might have confused you. In Python you have to either if value=="" or value is None instead. You can use also if value in ["",None]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AntonioMrtz , sorry for that i knew this still made an error.

@@ -81,6 +81,7 @@ def _set_attributes(self, config_section: str):
for key, value in self.config.items(config_section):
if value == "":
Copy link
Owner

Choose a reason for hiding this comment

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

As i said this has to be if value == "" or value is None

@AntonioMrtz AntonioMrtz merged commit 41b57c2 into AntonioMrtz:master Jul 16, 2024
@aarshgupta24 aarshgupta24 deleted the refactor/warning-logs branch July 16, 2024 18:21
@AntonioMrtz AntonioMrtz linked an issue Jul 16, 2024 that may be closed by this pull request
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.

Warning logs for default selections & mappers
2 participants