-
Notifications
You must be signed in to change notification settings - Fork 75
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
Conversation
ff61ceb
to
063d74a
Compare
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. |
063d74a
to
3529d12
Compare
3529d12
to
41f6abd
Compare
41f6abd
to
242ad4e
Compare
uaclient/cli.py
Outdated
LOG.warning(NEW_VERSION_NOTICE.format(version=new_version)) | ||
print(msg, file=sys.stderr) |
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.
Shouldn't this be a event.info
call ?
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.
Yep it probably should, and same for the others, updating
uaclient/cli.py
Outdated
) | ||
LOG.warning(msg) | ||
print(msg, file=sys.stderr) |
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.
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) |
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 think it should be fine to use print
, but I just want to double check if we should change to event.info
as well
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'm leaving these as print
s because they only happen in really broken scenarios, and importing event_logger
is a circular dependency
242ad4e
to
4df6b40
Compare
@lucasmoura updated! |
4df6b40
to
735e7b7
Compare
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
Does this PR require extra reviews?