Skip to content

Commit

Permalink
fix: reflect logger changes during life time of task (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
chamini2 authored Sep 18, 2024
1 parent 47c4a1b commit a431995
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/isolate/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _run_task(self, task: RunTask) -> Iterator[definitions.PartialRunResult]:
StatusCode.INVALID_ARGUMENT,
)

log_handler = LogHandler(messages, logger=task.logger)
log_handler = LogHandler(messages, task=task)

run_settings = replace(
self.default_settings,
Expand Down Expand Up @@ -480,10 +480,11 @@ def _proxy_to_queue(
@dataclass
class LogHandler:
messages: Queue
logger: IsolateLogger = ENV_LOGGER
# Reference to the task so we can change the logger
task: RunTask

def handle(self, log: Log) -> None:
self.logger.log(log.level, log.message, source=log.source)
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:
Expand Down

0 comments on commit a431995

Please sign in to comment.