Repository navigation
fix!: preserve streamed log severity and drain async logs on stop - #1229
Open
pcbeingused333 wants to merge 3 commits into
Open
pcbeingused333 wants to merge 3 commits into
pcbeingused333 wants to merge 3 commits into
Conversation
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1180
Streamed logs currently infer severity from substrings anywhere in a message, so
INFO Saved ERROR_PAGE screenshotbecomes 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.timeoutraisesTimeoutError; 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.