Skip to content

Commit

Permalink
feat: server skips empty logs if SKIP_EMPTY_LOGS == 1 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
mederka authored Sep 25, 2024
1 parent daa8adb commit c4790e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/isolate/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit c4790e3

Please sign in to comment.