From 56540d844611ef3d2e5734e3d713f3c749790583 Mon Sep 17 00:00:00 2001 From: Meder Kamalov Date: Wed, 25 Sep 2024 20:26:25 +0200 Subject: [PATCH] feat: server skips empty logs if SKIP_EMPTY_LOGS == 1 --- src/isolate/server/server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/isolate/server/server.py b/src/isolate/server/server.py index 0b649ee..d06cb52 100644 --- a/src/isolate/server/server.py +++ b/src/isolate/server/server.py @@ -36,6 +36,7 @@ from isolate.server.interface import from_grpc, to_grpc EMPTY_MESSAGE_INTERVAL = float(os.getenv("ISOLATE_EMPTY_MESSAGE_INTERVAL", "600")) +SKIP_EMPTY_LOGS = os.getenv("ISOLATE_SKIP_EMPTY_LOGS") == "1" MAX_GRPC_WAIT_TIMEOUT = float(os.getenv("ISOLATE_MAX_GRPC_WAIT_TIMEOUT", "10.0")) # Whether to inherit all the packages from the current environment or not. @@ -485,8 +486,9 @@ class LogHandler: task: RunTask def handle(self, log: Log) -> None: - self.task.logger.log(log.level, log.message, source=log.source) - self._add_log_to_queue(log) + if not SKIP_EMPTY_LOGS or log.message.strip(): + self.task.logger.log(log.level, log.message, source=log.source) + self._add_log_to_queue(log) def _add_log_to_queue(self, log: Log) -> None: grpc_log = cast(definitions.Log, to_grpc(log))