Skip to content

Code Quality: Migrate logger.py to structlog for robust JSON logs - #257

Open
pradeep0153 wants to merge 1 commit into
sreerevanth:mainfrom
pradeep0153:fixes/issue-245-migrate-logger-structlog
Open

Code Quality: Migrate logger.py to structlog for robust JSON logs#257
pradeep0153 wants to merge 1 commit into
sreerevanth:mainfrom
pradeep0153:fixes/issue-245-migrate-logger-structlog

Conversation

@pradeep0153

Copy link
Copy Markdown

Closes #245.

Description

This PR executes a foundational architectural refactoring of the telemetry and logging layer within Repopilot. The current logger.py implemented a custom, brittle JSONL writer for appending iteration data (<run_id>.jsonl).

As the project scaled and we added more telemetry (sandbox execution times, token counts, linter outputs), manually constructing and appending JSON dictionaries became highly error-prone. A single unescaped quote or nested un-serializable object caused the json.dumps() call to violently throw an exception, crashing the entire agent loop just to write a log line. Furthermore, the human-readable logs (_human.log) completely lacked consistent formatting, levels, and chronological timestamping. We needed to execute a major code quality initiative by migrating to an industry-standard, structured logging pipeline.

Changes Made

  • Telemetry Audit: Systematically audited all logging calls across the Repopilot codebase and ripped out the custom logger.py string-formatting implementations.
  • Structlog Pipeline: Implemented a strict Structured Logging pipeline utilizing the industry-standard structlog library.
  • Processor Configuration: The architecture must now mathematically route all logs through two dedicated processors. The ConsoleRenderer dynamically formats logs for the CLI and _human.log with colors and clean alignment. The JSONRenderer strictly handles the .jsonl telemetry file.
  • Execution: This standardizes log levels across the entire application, automatically injects timestamps and run IDs into every payload, and guarantees absolute serialization safety.

Impact

  • Observability & Code Quality: Relying on custom json.dumps logic for critical telemetry is a fatal anti-pattern that guarantees data corruption and agent crashes. By engineering this structlog pipeline, we mathematically eradicate logging exceptions. We guarantee that the JSONL telemetry files are structurally flawless, enabling seamless ingestion into Datadog or ELK, while drastically improving the local debugging experience for developers.

@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

@pradeep0153 is attempting to deploy a commit to the sreerevanth's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code Quality: Migrate logger.py to structlog for robust JSON logs

2 participants