Skip to content

Replace f-string log calls to structured kwargs logs#9370

Open
Dhanus3133 wants to merge 5 commits into
opsmill:stablefrom
Dhanus3133:1131/task-replace-old-logger-calls
Open

Replace f-string log calls to structured kwargs logs#9370
Dhanus3133 wants to merge 5 commits into
opsmill:stablefrom
Dhanus3133:1131/task-replace-old-logger-calls

Conversation

@Dhanus3133
Copy link
Copy Markdown
Contributor

@Dhanus3133 Dhanus3133 commented May 28, 2026

Why

LOGGER calls across the backend used stdlib logging with f-string messages, so fields weren't queryable in JSON logs.

Closes #1131

What changed

  • Replaced stdlib logging.getLogger() with structlog get_logger(); converted f-string log calls to structured kwargs on safe (non-Prefect) loggers, and added exc_info to exception logs.

Checklist

  • Tests added/updated
  • Changelog entry added (uv run towncrier create ...)
  • External docs updated (if user-facing or ops-facing change)
  • Internal .md docs updated (internal knowledge and AI code tools knowledge)
  • I have reviewed AI generated content

Summary by cubic

Replaced f-string logs with structured structlog kwargs and added exc_info to preserve tracebacks, making JSON logs easier to query. Addresses Linear 1131.

  • Refactors
    • Switched stdlib logging.getLogger() to structlog.get_logger() where safe; flows use Prefect get_run_logger.
    • Converted logs to keyword fields across auth, diff/merge, git, GraphQL, migrations, tasks, webhooks, database, and HTTP client.
    • Standardized batch/query messages with clear fields (e.g., limit, offset, batch, num_nodes, refs) and added exc_info to errors/warnings.
    • Removed unused loggers in event and approval modules; updated webhook test to assert the structured duplicate-header warning.

Written for commit 4f5093a. Summary will update on new commits.

Review in cubic

@Dhanus3133 Dhanus3133 requested a review from a team as a code owner May 28, 2026 10:41
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.

task: Replace old LOGGER calls with structlog

1 participant