From d6a08df886d9c5fc9162825560a25457a233e56c Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Wed, 25 Dec 2024 03:47:53 +0000 Subject: [PATCH] otaclient: use get_burst_suppressed_logger --- src/otaclient/_status_monitor.py | 14 +++----------- src/otaclient/grpc/api_v2/ecu_tracker.py | 14 +++----------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/otaclient/_status_monitor.py b/src/otaclient/_status_monitor.py index 9db09cfe0..6aba1b1c8 100644 --- a/src/otaclient/_status_monitor.py +++ b/src/otaclient/_status_monitor.py @@ -35,19 +35,11 @@ UpdateTiming, ) from otaclient._utils import SharedOTAClientStatusWriter -from otaclient_common.logging import BurstSuppressFilter +from otaclient_common.logging import get_burst_suppressed_logger logger = logging.getLogger(__name__) -burst_suppressed_logger = logging.getLogger(f"{__name__}.shm_push") -# NOTE: for request_error, only allow max 6 lines of logging per 30 seconds -burst_suppressed_logger.addFilter( - BurstSuppressFilter( - f"{__name__}.shm_push", - upper_logger_name=__name__, - burst_round_length=30, - burst_max=6, - ) -) +# NOTE: suppress error logging for pushing OTA status to shm +burst_suppressed_logger = get_burst_suppressed_logger(f"{__name__}.shm_push") _status_report_queue: queue.Queue | None = None diff --git a/src/otaclient/grpc/api_v2/ecu_tracker.py b/src/otaclient/grpc/api_v2/ecu_tracker.py index ba454f138..ee7a26f2c 100644 --- a/src/otaclient/grpc/api_v2/ecu_tracker.py +++ b/src/otaclient/grpc/api_v2/ecu_tracker.py @@ -27,19 +27,11 @@ from otaclient.grpc.api_v2.ecu_status import ECUStatusStorage from otaclient_api.v2 import types as api_types from otaclient_api.v2.api_caller import ECUNoResponse, OTAClientCall -from otaclient_common.logging import BurstSuppressFilter +from otaclient_common.logging import get_burst_suppressed_logger logger = logging.getLogger(__name__) -burst_suppressed_logger = logging.getLogger(f"{__name__}.local_ecu_check") -# NOTE: for request_error, only allow max 6 lines of logging per 30 seconds -burst_suppressed_logger.addFilter( - BurstSuppressFilter( - f"{__name__}.local_ecu_check", - upper_logger_name=__name__, - burst_round_length=30, - burst_max=6, - ) -) +# NOTE: suppress error loggings from checking local ECU's status shm +burst_suppressed_logger = get_burst_suppressed_logger(f"{__name__}.local_ecu_check") # actively polling ECUs status until we get the first valid response # when otaclient is just starting.