From 2b7a8eff8748dc02afbaf39916bc94180a4b2018 Mon Sep 17 00:00:00 2001 From: calvinmwadime Date: Wed, 19 Apr 2023 18:25:45 +0300 Subject: [PATCH] logging_revamp: add null handler in api endpoint --- uaclient/api/api.py | 4 ++++ uaclient/conftest.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/uaclient/api/api.py b/uaclient/api/api.py index ac849d9b9c..625dc6eef2 100644 --- a/uaclient/api/api.py +++ b/uaclient/api/api.py @@ -1,3 +1,4 @@ +import logging from importlib import import_module from typing import Callable, List @@ -35,6 +36,9 @@ def call_api( endpoint_path: str, options: List[str], cfg: UAConfig ) -> APIResponse: + # setup null handler for all API endpoints + logging.getLogger("uaclient").addHandler(logging.NullHandler()) + if endpoint_path not in VALID_ENDPOINTS: return error_out( APIError( diff --git a/uaclient/conftest.py b/uaclient/conftest.py index d61bad08d4..f73c20f14e 100644 --- a/uaclient/conftest.py +++ b/uaclient/conftest.py @@ -135,7 +135,6 @@ def clear_handlers(): def logging_sandbox(): # Monkeypatch a replacement root logger, so that our changes to logging # configuration don't persist outside of the test - # root_logger = logging.RootLogger(logging.WARNING) root_logger = logging.getLogger("uaclient") root_logger.setLevel(logging.WARNING)