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: fix calls to logging to use correct logger #2679

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion uaclient/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def attach_with_token(
)
except exceptions.UrlError as e:
with util.disable_log_to_console():
logging.exception(str(e))
LOG.exception(str(e))
raise exceptions.ConnectivityError()

cfg.machine_token_file.write(new_machine_token)
Expand Down
4 changes: 2 additions & 2 deletions uaclient/entitlements/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def handle_required_packages(self) -> bool:

package_names = [package["name"] for package in required_packages]
msg = messages.INSTALLING_PACKAGES.format(" ".join(package_names))
logging.debug(msg)
LOG.debug(msg)
event.info(msg)
apt.run_apt_install_command(package_names)

Expand All @@ -581,7 +581,7 @@ def handle_removing_required_packages(self) -> bool:
]
package_names_str = " ".join(package_names)
msg = messages.UNINSTALLING_PACKAGES.format(package_names_str)
logging.debug(msg)
LOG.debug(msg)
event.info(msg)
apt.remove_packages(
package_names,
Expand Down
9 changes: 5 additions & 4 deletions uaclient/entitlements/landscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from uaclient.entitlements.base import UAEntitlement
from uaclient.entitlements.entitlement_status import ApplicationStatus

LOG = logging.getLogger(util.replace_top_level_logger_name(__name__))
event = event_logger.get_event_logger()

LANDSCAPE_CLIENT_PACKAGE_NAME = "landscape-client"
Expand All @@ -26,7 +27,7 @@ def _perform_enable(self, silent: bool = False) -> bool:
if self.assume_yes and "--silent" not in cmd:
cmd += ["--silent"]

logging.debug(messages.EXECUTING_COMMAND.format(" ".join(cmd)))
LOG.debug(messages.EXECUTING_COMMAND.format(" ".join(cmd)))
event.info(
util.redact_sensitive_logs(
messages.EXECUTING_COMMAND.format(" ".join(cmd))
Expand Down Expand Up @@ -65,15 +66,15 @@ def _perform_disable(self, silent: bool = False) -> bool:
system.subp(cmd)
except exceptions.ProcessExecutionError as e:
with util.disable_log_to_console():
logging.error(e)
LOG.error(e)
event.info(str(e).strip())
event.warning(str(e), self.name)

msg = messages.BACKING_UP_FILE.format(
original=LANDSCAPE_CLIENT_CONFIG_PATH,
backup=LANDSCAPE_CLIENT_CONFIG_PATH_DISABLE_BACKUP,
)
logging.debug(msg)
LOG.debug(msg)
event.info(msg)
try:
os.rename(
Expand All @@ -82,7 +83,7 @@ def _perform_disable(self, silent: bool = False) -> bool:
)
except FileNotFoundError as e:
with util.disable_log_to_console():
logging.error(e)
LOG.error(e)
event.info(str(e))
event.warning(str(e), self.name)

Expand Down
Loading