Skip to content

refactor(P4a): stop reconfiguring root logging at import in 20 modules#271

Merged
divyasinghds merged 1 commit into
developfrom
refactor/p4a-remove-import-logging
Jun 16, 2026
Merged

refactor(P4a): stop reconfiguring root logging at import in 20 modules#271
divyasinghds merged 1 commit into
developfrom
refactor/p4a-remove-import-logging

Conversation

@LukasWodka

Copy link
Copy Markdown
Collaborator

Summary

Structural refactor — phase P4 (config injection), first slice. Twenty modules (every validator + database + file_transfer) called setup_logging(config) at import time — reconfiguring the root logger's handlers globally, 20× on every import. That's an import-time side effect a library shouldn't have. The entrypoints (cli/run.main and the template scripts) already call setup_logging() at startup, so the per-module calls were redundant.

This removes the import-time setup_logging(config) call + its now-unused import from all 20 modules. Each module keeps config = Config() and logger.setLevel(config.LOG_LEVEL) — the full config-by-construction + env-var-bridge removal are the next P4 slices (below). Logging is now configured once, at the app entrypoint.

Behaviour preservation

Root logging is still configured by the entrypoint; child loggers inherit. Diff is exactly the 20 files (just the 2-line removal each).

What's next in P4

This was the safe, e2e-independent slice. The config-by-construction core follows:

  • P4b — inject Config into the file validators (via the registry's build_validators) instead of the module-level global.
  • P4cfile_transfer takes resolved paths as parameters; delete cli/run._set_legacy_env_vars (the os.environ bridge). The e2e-sensitive part — now gateable with the local harness (Docker confirmed working).

(Pre-existing flake8 noise in some touched files — unused List/Optional/pd etc. — is unrelated and left out of scope.)

🤖 Generated with Claude Code

Structural refactor phase P4 (backend#796), first slice. Twenty modules (every
validator + database + file_transfer) called setup_logging(config) at IMPORT
time — reconfiguring the root logger's handlers globally, 20x on every import:
an import-time side effect a library shouldn't have. The entrypoints
(cli/run.main and the template scripts) already call setup_logging() at
startup, so the per-module calls were redundant.

Removes the import-time setup_logging(config) call + its now-unused import from
all 20 modules. Each module's `config = Config()` and
`logger.setLevel(config.LOG_LEVEL)` are kept (full config-by-construction + the
env-var-bridge removal are the next P4 slices). Logging is now configured once,
at the app entrypoint.

Behaviour-preserving: root logging is still configured by the entrypoint; child
loggers inherit. Full unit suite 1078 passed, 96.9% coverage; e2e (real MySQL)
23 passed, 1 xpassed — characterization goldens unchanged.

Next: P4b (inject Config into the file validators) and P4c (file_transfer takes
paths; delete the cli/run env-var bridge) — the config-by-construction core,
now gateable with the local e2e harness.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
Collaborator Author

👋 Heads-up — Code review queue is at 11 / 8

Above the WIP limit. The team convention is to review existing PRs before opening new work.

Open PRs currently in Code review (oldest first):

Pull from review before opening new work. (This is a nudge from the kanban WIP check, not a block.)

@divyasinghds divyasinghds merged commit 03df536 into develop Jun 16, 2026
6 checks passed
@divyasinghds divyasinghds deleted the refactor/p4a-remove-import-logging branch June 16, 2026 09:14
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