Skip to content

Add structured logging and error context to runtime layer #9

@coderabbitai

Description

@coderabbitai

Background

PR #6 (#6) introduced GitHub API mutations, TOML config loading, and network I/O in create_labels/github.py, create_labels/config.py, create_labels/sync.py, and create_labels/cli.py. None of these modules emit log output, making it difficult to diagnose failures in production or CI without attaching a debugger.

Required work

Add a logging call hierarchy across the runtime layer:

  • create_labels.github: DEBUG log at token/repo resolution; INFO log before and after each GitHub API call; ERROR log (with HTTP status when available) on GitHubError.
  • create_labels.sync: DEBUG log per label indicating the determined action (created/updated/unchanged); WARNING on unexpected RuntimeError from GitHub.
  • create_labels.config: DEBUG log when a config file is loaded; ERROR log on ConfigError.
  • create_labels.cli: configure a root logging.basicConfig at WARNING level by default; expose a --verbose / -v flag that sets the level to DEBUG.

Use logging.getLogger(__name__) in each module. Do not use f-strings inside log calls; use %-style formatting to comply with the project's ruff logging rules (logging-fstring-interpolation is already listed as a linting rule in pyproject.toml).

Acceptance criteria

  • Each runtime module uses a module-level logger = logging.getLogger(__name__).
  • Key decision points (token resolution, API calls, label actions) emit DEBUG or INFO entries.
  • --verbose flag enables DEBUG output.
  • make lint and make test pass with logging added.
  • docs/developers-guide.md is updated to document the logging strategy.

Raised by @leynos following review of PR #6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions