Skip to content

Added application-wide logging support for easier debugging#20

Open
ikabrain wants to merge 15 commits into
kaurmanjot20:mainfrom
ikabrain:fix/exception-logging
Open

Added application-wide logging support for easier debugging#20
ikabrain wants to merge 15 commits into
kaurmanjot20:mainfrom
ikabrain:fix/exception-logging

Conversation

@ikabrain

@ikabrain ikabrain commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Inlinea had a number of except blocks that swallowed failures silently, including but not limited to a
print() in a render thread, bare except: pass around teardown, save errors that only surfaced as a toast, and PDF/annotation/session failures that vanished entirely.

This PR adds Python's standard logging throughout so those sites actually emit output, and configures the root logger so anything at WARNING+ lands on stderr (visible in a terminal or journalctl when launched from the desktop).

Changes

  • Configured the root logger in __main__.py to write to stderr at WARNING by default, with full DEBUG output via the INLINEA_DEBUG=1 env var.
  • Added module-level logging.getLogger(__name__) loggers to document/engine/pool.py, app.py, document/pdf_storage.py, document/loading.py, session_manager.py, ui/page_view.py, and utils/links.py.
  • Replaced the print() in the render worker's error path (document/engine/pool.py) with logger.exception, so render-thread tracebacks are captured instead of lost to stdout.
  • CSS load failures in app.py now emit a warning instead of being swallowed; switched the guard from os.path.exists to os.access(..., os.R_OK) because GTK 4's load_from_path warns rather than raising on an unreadable file, so
    the old except was dead code.
  • Narrowed two bare except: / except Exception: blocks around disconnect_by_func in window.py to except TypeError:, so they no longer catch KeyboardInterrupt or mask unrelated errors.
  • Annotation load failures, per-annotation write failures, and metadata-parse errors in document/pdf_storage.py now log at appropriate levels instead of discarding the exception.
  • Save and Save-As failures in window.py (which already showed a "Save Failed" toast) now also logger.exception the cause; the Save-All-&-Quit loop logs too, so it matches the Ctrl+S / Save-As paths instead of being journal-silent.
  • Session-restore failures in session_manager.py log a warning instead of silently returning None; the app still starts.
  • URI-launch failures on link click (ui/page_view.py) and link-extraction failures (utils/links.py) now log instead of except Exception: pass.
  • PDF open failures in document/loading.py log a warning with the underlying GLib.Error reason (encrypted / damaged / etc.) before returning None; previously the cause was discarded before the UI ever saw it.

Tested locally on Arch Linux (python3 -m inlinea): clean launch with no spurious warnings, and each logging site verified by fault injection at unreadable CSS, corrupt session.json, a read-only save target, a non-PDF file, and broken annotation metadata under INLINEA_DEBUG=1. Each produced the expected warning/exception output while the happy path stayed silent.

Copilot AI review requested due to automatic review settings June 1, 2026 17:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds structured Python logging across the application and documents how to enable debug output.

Changes:

  • Introduces per-module logger usage and replaces silent except: pass / print(...) with logger.warning/debug/exception(...).
  • Adds INLINEA_DEBUG-driven logging configuration in __main__.py.
  • Documents debugging/logging workflow in the README.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/inlinea/window.py Logs save-related failures and narrows broad exception handling on disconnect.
src/inlinea/utils/links.py Logs link-extraction failures instead of silently ignoring them.
src/inlinea/ui/page_view.py Logs URI-launch failures on link clicks.
src/inlinea/session_manager.py Logs when the session file cannot be read/parsed.
src/inlinea/document/pdf_storage.py Logs failures opening PDFs and parsing/writing annotations.
src/inlinea/document/loading.py Logs Poppler open failures with context.
src/inlinea/document/engine/pool.py Replaces print with structured exception logging in render worker.
src/inlinea/app.py Improves CSS load diagnostics and logs failures.
src/inlinea/main.py Configures stderr logging and debug mode via environment variable.
README.md Adds logging/debugging instructions for terminal and journald workflows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/inlinea/window.py
Comment thread src/inlinea/window.py
Comment thread README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants