Skip to content

Replace print() error output with structured logging #68

@bradjin8

Description

@bradjin8

Repository: cppa-cursor-browser
Assignee: Brad @bradjin8
Points: 3
Severity: High

Problem

Errors that survive the except Exception: pass discard layer arrive at the service tier as unstructured print() statements — e.g., in services/workspace_tabs.py and services/workspace_listing.py. These prints carry no severity level, no structured fields, and no correlation to the triggering request. In a production deployment behind a WSGI server (gunicorn, as documented in DEPLOYMENT.md), print() output may route to stdout, a log file, or nowhere, depending on capture configuration. The project's own SchemaError demonstrates that structured error design is understood — it was not applied to the parse-and-assemble layer where errors are most frequent.

Acceptance Criteria

  • All print(f"Error ...") and print(f"Warning ...") calls in services/ are replaced with logging.error() or logging.warning() calls
  • Each service module uses logger = logging.getLogger(__name__)
  • Log messages include structured context: module name, function name, entity identifier, and exception type
  • A basic logging configuration is established in the application entry point (e.g., app.py or the Flask app factory) if one does not already exist
  • No bare print() calls for error reporting remain in services/ or api/ directories
  • Tests pass in CI
  • PR approved by at least 1 reviewer

Implementation Notes

This item naturally pairs with item 1 (except-pass replacement). In each affected file, add import logging and logger = logging.getLogger(__name__) at the top. Replace print(f"Error parsing composer {cid}: {e}") with logger.error("Failed to parse composer %s: %s", cid, e, exc_info=True). The exc_info=True parameter captures the full traceback without requiring a separate traceback.print_exc() call. In the Flask app factory, configure logging.basicConfig(level=logging.INFO) as a default. The DEPLOYMENT.md threading matrix already documents gunicorn deployment — ensure the logging guidance is compatible with gunicorn's log capture.

References

  • Eval finding: Test 10 (Error Reporting / Observability) — part of the "Silent Failure Chain" compound
  • Related files: services/workspace_tabs.py, services/workspace_listing.py, services/workspace_resolver.py, app.py

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions