Skip to content

fix!: preserve streamed log severity and drain async logs on stop - #1229

Open
pcbeingused333 wants to merge 3 commits into
apify:masterfrom
pcbeingused333:fix/c3526-streamed-log
Open

pcbeingused333 wants to merge 3 commits into
apify:masterfrom
pcbeingused333:fix/c3526-streamed-log

Conversation

@pcbeingused333

Copy link
Copy Markdown

Fixes #1180

Streamed logs currently infer severity from substrings anywhere in a message, so INFO Saved ERROR_PAGE screenshot becomes ERROR. Read only the level token after the platform timestamp and optional bracketed logger name, preserving the standard logging aliases and falling back to INFO when the token is absent or unknown.

Give asynchronous log streaming a one-second grace period on stop so in-flight final chunks can arrive. Cancel streams that remain open after that period. Caller cancellation cancels and awaits the streaming task, clears its handle, and propagates without fetching the whole log. Normal stopping retains buffered-tail flushing and the whole-log fallback when no bytes arrived.

BREAKING CHANGE: Redirected log severity now comes from the level token rather than words in the message body. Asynchronous stop may wait up to one second before cancelling an open stream.

Testing and validation

Unit tests cover misleading message text, bracketed logger names, unknown or absent levels, delivery on the next event-loop turn, and cancellation of a silent stream. Explicit caller cancellation leaves the stopping task cancelled, and an enclosing asyncio.timeout raises TimeoutError; neither path fetches the whole log. The focused suite passes all 16 tests (python -m pytest tests/unit/test_streamed_log.py -q). The two caller-cancellation regressions fail against the previous revision (14 passed, 2 failed). Ruff lint and format checks pass.

AI assistance: This change and its tests were prepared with OpenAI Codex.

Read the level token after the platform timestamp and optional logger prefix. Allow in-flight asynchronous log chunks to finish for one second before cancellation.

BREAKING CHANGE: Redirected severity follows the level token rather than message substrings; async stop may wait up to one second before cancelling.
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streamed log redirection guesses levels from any substring and drops in-flight lines on async stop

1 participant