Skip to content

Commit 76a93b0

Browse files
committed
fix: Keep the existing message when reporting a failed log tail flush
1 parent 2920b6d commit 76a93b0

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/apify_client/_streamed_log.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def _stream_log(self) -> None:
194194
except Exception:
195195
# A truncated stream leaves an undecodable tail, which is worth a traceback even while a stop
196196
# is in progress.
197-
self._to_logger.exception('Flushing the buffered log tail failed:')
197+
self._to_logger.exception('Log redirection stopped due to unexpected error:')
198198
except Exception as exc:
199199
if self._stop_logging:
200200
# `stop` closed the stream out from under the read, so the failure is expected.
@@ -282,7 +282,7 @@ async def _stream_log(self) -> None:
282282
except Exception:
283283
# A truncated stream leaves an undecodable tail. Keeping the failure here also keeps the
284284
# cancellation `stop` raised propagating, so the task ends up cancelled as asyncio expects.
285-
self._to_logger.exception('Flushing the buffered log tail failed:')
285+
self._to_logger.exception('Log redirection stopped due to unexpected error:')
286286
except Exception as exc:
287287
if self._log_client._http_client.is_timeout_error(exc): # noqa: SLF001
288288
# A timeout on the long-lived stream is an expected terminal condition, not an error.

‎tests/unit/test_logging.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ def generate_logs() -> Iterator[bytes]:
13151315
assert any(
13161316
record.levelno == logging.ERROR
13171317
and record.exc_info is not None
1318-
and record.message == 'Flushing the buffered log tail failed:'
1318+
and record.message == 'Log redirection stopped due to unexpected error:'
13191319
for record in caplog.records
13201320
), f'The truncated tail was not reported. Got: {[record.message for record in caplog.records]}'
13211321

@@ -1359,7 +1359,7 @@ def generate_logs() -> Iterator[bytes]:
13591359
assert any(
13601360
record.levelno == logging.ERROR
13611361
and record.exc_info is not None
1362-
and record.message == 'Flushing the buffered log tail failed:'
1362+
and record.message == 'Log redirection stopped due to unexpected error:'
13631363
for record in caplog.records
13641364
), f'The truncated tail was not reported. Got: {[record.message for record in caplog.records]}'
13651365

0 commit comments

Comments
 (0)