Worker and web logging with configurable level and file #13

Manually merged
marvin8 merged 3 commits from feat/issue-11-worker-logging into main 2026-10-15 08:01:56 +00:00
Collaborator

Both processes were completely silent: no logging anywhere in the codebase, job failures recorded only in the jobs table, and an operator running xique-worker had no way to see a missing XIQUE_TMDB_TOKEN or any other failure without querying the database.

Closes #11

What this does

  • XIQUE_LOG_LEVEL (default INFO, case-insensitive stdlib level names) and XIQUE_LOG_FILE (default unset) join the XIQUE_* settings family.
  • New xique.logsetup.configure_logging: errors and above on stdout; with XIQUE_LOG_FILE set, a rotating file handler (5 MB, 3 backups) at the configured level down to DEBUG. Handlers are marked and replaced on reconfiguration, so repeated calls never stack output. The root logger sits at the least severe installed sink level.
  • Worker logging: startup line with database path, poll interval, and stale-job recovery count; job started/completed at DEBUG; known job failures at ERROR reusing the existing token-free jobs-table messages (new _fail_logged helper); unexpected handler exceptions at ERROR with full traceback via logger.exception. Jellyfin sync result counts at DEBUG. Idle cycles stay quiet at INFO.
  • xique-web configures logging before uvicorn starts.
  • README documents both settings and the logging behaviour.

Notes for review

  • No job behaviour changed: statuses, messages, and dispatch flow are untouched — only log calls added alongside.
  • Known-failure paths (bad Trakt payload, missing TMDB token, TraktImportError, TMDB errors) log at ERROR with the same token-free message stored in jobs.error.
  • .gitignore now excludes the local runtime database files (xique.db*) that were untracked clutter in the worktree.

Testing

  • New tests/test_logsetup.py (11 tests, written RED first): settings validation and defaults, handler levels and sink routing, idempotent reconfiguration, DEBUG-to-file delivery, worker failure/traceback/lifecycle records, and both entry points calling configure_logging before any work.
  • Full uv run nox green at commit 147729e except the zaojun/pre-commit sessions, which fail on main too due to upstream releases (fastapi 0.143.1, pydantic 2.14.1, pydantic-settings 2.16.0). #12 bumps those pins; after it merges I will rebase this branch so CI runs clean.
Both processes were completely silent: no logging anywhere in the codebase, job failures recorded only in the `jobs` table, and an operator running `xique-worker` had no way to see a missing `XIQUE_TMDB_TOKEN` or any other failure without querying the database. Closes #11 ## What this does - `XIQUE_LOG_LEVEL` (default `INFO`, case-insensitive stdlib level names) and `XIQUE_LOG_FILE` (default unset) join the `XIQUE_*` settings family. - New `xique.logsetup.configure_logging`: errors and above on stdout; with `XIQUE_LOG_FILE` set, a rotating file handler (5 MB, 3 backups) at the configured level down to `DEBUG`. Handlers are marked and replaced on reconfiguration, so repeated calls never stack output. The root logger sits at the least severe installed sink level. - Worker logging: startup line with database path, poll interval, and stale-job recovery count; job started/completed at DEBUG; known job failures at ERROR reusing the existing token-free `jobs`-table messages (new `_fail_logged` helper); unexpected handler exceptions at ERROR with full traceback via `logger.exception`. Jellyfin sync result counts at DEBUG. Idle cycles stay quiet at INFO. - `xique-web` configures logging before uvicorn starts. - README documents both settings and the logging behaviour. ## Notes for review - No job behaviour changed: statuses, messages, and dispatch flow are untouched — only log calls added alongside. - Known-failure paths (bad Trakt payload, missing TMDB token, `TraktImportError`, TMDB errors) log at ERROR with the same token-free message stored in `jobs.error`. - `.gitignore` now excludes the local runtime database files (`xique.db*`) that were untracked clutter in the worktree. ## Testing - New `tests/test_logsetup.py` (11 tests, written RED first): settings validation and defaults, handler levels and sink routing, idempotent reconfiguration, DEBUG-to-file delivery, worker failure/traceback/lifecycle records, and both entry points calling `configure_logging` before any work. - Full `uv run nox` green at commit `147729e` except the zaojun/pre-commit sessions, which fail on `main` too due to upstream releases (fastapi 0.143.1, pydantic 2.14.1, pydantic-settings 2.16.0). #12 bumps those pins; after it merges I will rebase this branch so CI runs clean.
XIQUE_LOG_LEVEL / XIQUE_LOG_FILE settings fields plus a configure_logging
stub; the full logging contract is pinned by failing tests: stdout ERROR
handler, file handler at the configured level, idempotent handler install,
worker failure/traceback/lifecycle records, and entry-point wiring.
configure_logging installs a marked stdout handler at ERROR and, when
XIQUE_LOG_FILE is set, a rotating file handler at the configured level;
repeated calls replace earlier handlers. The root logger sits at the least
severe installed sink level. The worker logs known job failures at ERROR
with the token-free jobs-table message, unexpected handler exceptions at
ERROR with traceback, and job lifecycle at DEBUG; jellyfin sync counts log
at DEBUG. Both entry points configure logging before any work.
📝 docs: document XIQUE_LOG_LEVEL and XIQUE_LOG_FILE
Some checks failed
/ pr-review (pull_request) Successful in 11s
/ gitleaks (pull_request) Successful in 22s
/ checks (pull_request) Failing after 4m36s
/ container (pull_request) Has been skipped
/ publish-container (pull_request) Has been skipped
/ deploy-docs (pull_request) Has been skipped
147729e024
agent-pi force-pushed feat/issue-11-worker-logging from 147729e024
Some checks failed
/ pr-review (pull_request) Successful in 11s
/ gitleaks (pull_request) Successful in 22s
/ checks (pull_request) Failing after 4m36s
/ container (pull_request) Has been skipped
/ publish-container (pull_request) Has been skipped
/ deploy-docs (pull_request) Has been skipped
to 5e82f6ef12
All checks were successful
/ pr-review (pull_request) Successful in 13s
/ gitleaks (pull_request) Successful in 23s
/ checks (pull_request) Successful in 5m27s
/ container (pull_request) Has been skipped
/ publish-container (pull_request) Has been skipped
/ deploy-docs (pull_request) Has been skipped
2026-10-15 07:43:38 +00:00
Compare
marvin8 approved these changes 2026-10-15 08:01:04 +00:00
marvin8 manually merged commit 4b62f74e24 into main 2026-10-15 08:01:56 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
marvin8/xique!13
No description provided.