feat(logging): rotating file log + level control; stop leaking exceptions into the UI - #295
Merged
Conversation
…ions into the UI
Attach a RotatingFileHandler (LOGS_DIR/stemdeck.log, 5 MB x 3, timestamped)
to the stemdeck logger so server and Docker deployments keep an on-disk
trail -- until now LOGS_DIR existed but nothing ever wrote to it, and
stdout scrollback was the only record. Best-effort: a read-only FS
degrades to stdout-only logging instead of failing startup.
Level is now controllable: STEMDECK_LOG_LEVEL=DEBUG|INFO|WARNING, with
STEMDECK_DEBUG=1 as shorthand. This also un-deadens the analyze
diagnostics ("chroma:", "key candidates:") -- they are logger.debug
calls that could never emit under the previous hardcoded INFO level,
despite the comment claiming otherwise.
Also stop interpolating raw exception reprs into the user-visible
"Analysis skipped" stage message; the traceback is already in the log.
Closes #291
Closes #292
Closes #283
8 tasks
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.
Closes #291, closes #292, closes #283. First PR of Phase 1 (#272) — plan in #272 (comment) (PR-1A).
What
app/core/logging_setup.py— attaches aRotatingFileHandlerto thestemdecklogger:LOGS_DIR/stemdeck.log, 5 MB × 3 backups, UTF-8, timestamped one-char-level format.delay=Trueso nothing is touched until the first record, and a read-only FS degrades to stdout-only logging instead of failing startup. Idempotence guard souvicorn --reloadre-imports don't stack handlers. Propagation stays on — stdout behavior is unchanged, the file is additive (Server mode writes no log file at all #291).STEMDECK_LOG_LEVEL=DEBUG|INFO|WARNING(default INFO),STEMDECK_DEBUG=1shorthand. The analyze diagnostics (chroma:,key candidates:) arelogger.debugand could never emit under the previous hardcoded INFO level, despite the main.py comment claiming they showed — comment fixed, diagnostics now reachable (The analyze diagnostics are dead code at INFO level #292).analyze.pyno longer interpolates the raw exception repr into the user-visible "Analysis skipped (…)" stage line; the traceback was alreadylogger.exception'd (Internal exception text leaks into the UI stage line #283).Testing
tests/test_logging_setup.py: file created on first record, rotation bound honored, idempotence, env level resolution (incl. bogus value fallback + DEBUG shorthand precedence), unwritable LOGS_DIR degrades without raising.ruff check+ruff format --checkclean.