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

logging: no more cli console logging #2683

Merged
merged 1 commit into from
Aug 15, 2023
Merged

Conversation

orndorffgrant
Copy link
Collaborator

@orndorffgrant orndorffgrant commented Jul 31, 2023

Why is this needed?

This removes some old code around conditionally logging messages to the console. In most cases, that is what we do, and in some of the few cases where we didn't disable the console logger, that was a bug.

We should treat the console as our cli UX and treat the logs as logs. There should be no instance where a log message is also part of our UX. In the rare case where we want to print the same message to the User and our logs, then that can be two separate statements.

The exception is the --debug flag which is useful to include log statements in the middle of the console output - that functionality is kept and enhanced by removing the formatter that stripped a lot of useful information from those logs.

Test Steps

CI should pass.

Please review all instances of logging.info, logging.warn, logging.error, and logging.exception. Please double check that, where necessary, the messages are also printed/event.infoed properly. This includes statements that are not a part of the diff.

Checklist

  • I have updated or added any unit tests accordingly
  • I have updated or added any integration tests accordingly
  • Changes here need to be documented, and this was done in:

Does this PR require extra reviews?

  • Yes
  • No

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Jira: This PR is not related to a Jira item. (The PR title does not include a SC-#### reference)

GitHub Issues: No GitHub issues are fixed by this PR. (No commits have Fixes: #### references)

Launchpad Bugs: No Launchpad bugs are fixed by this PR. (No commits have LP: #### references)

Documentation: The changes in this PR do not require documentation changes.

👍 this comment to confirm that this is correct.

@orndorffgrant orndorffgrant marked this pull request as ready for review August 9, 2023 20:24
@orndorffgrant orndorffgrant changed the title wip: no more cli console logging logging: no more cli console logging Aug 10, 2023
uaclient/cli.py Outdated
LOG.warning(NEW_VERSION_NOTICE.format(version=new_version))
print(msg, file=sys.stderr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be a event.info call ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep it probably should, and same for the others, updating

uaclient/cli.py Outdated
)
LOG.warning(msg)
print(msg, file=sys.stderr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same event.info replacement here

@@ -10,22 +10,27 @@
import yaml
except ImportError:
LOG.error(MISSING_YAML_MODULE.msg)
print(MISSING_YAML_MODULE.msg, file=sys.stderr)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be fine to use print, but I just want to double check if we should change to event.info as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm leaving these as prints because they only happen in really broken scenarios, and importing event_logger is a circular dependency

@orndorffgrant
Copy link
Collaborator Author

@lucasmoura updated!

@lucasmoura lucasmoura merged commit 49cc486 into main Aug 15, 2023
23 checks passed
@lucasmoura lucasmoura deleted the no-more-console-logging branch August 15, 2023 20:32
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.

2 participants